@scpxl/nodejs-framework 1.0.24 → 1.0.27
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.
- package/README.md +65 -17
- package/dist/api-requester/api-requester.d.ts.map +1 -1
- package/dist/api-requester/api-requester.js +2 -1
- package/dist/api-requester/api-requester.js.map +2 -2
- package/dist/application/base-application.d.ts.map +1 -1
- package/dist/application/base-application.js +4 -3
- package/dist/application/base-application.js.map +2 -2
- package/dist/cache/manager.d.ts.map +1 -1
- package/dist/cache/manager.js +2 -1
- package/dist/cache/manager.js.map +2 -2
- package/dist/cli/index.js +7019 -83
- package/dist/cli/index.js.map +4 -4
- package/dist/cluster/cluster-manager.d.ts +3 -0
- package/dist/cluster/cluster-manager.d.ts.map +1 -1
- package/dist/cluster/cluster-manager.js +45 -8
- package/dist/cluster/cluster-manager.js.map +2 -2
- package/dist/database/dynamic-entity-form-decorators.d.ts +2 -2
- package/dist/database/dynamic-entity-form-decorators.d.ts.map +1 -1
- package/dist/database/dynamic-entity-form-decorators.js.map +1 -1
- package/dist/database/dynamic-entity.d.ts +21 -4
- package/dist/database/dynamic-entity.d.ts.map +1 -1
- package/dist/database/dynamic-entity.js +39 -10
- package/dist/database/dynamic-entity.js.map +2 -2
- package/dist/database/manager.d.ts.map +1 -1
- package/dist/database/manager.js +3 -2
- package/dist/database/manager.js.map +2 -2
- package/dist/error/error-reporter.d.ts +20 -7
- package/dist/error/error-reporter.d.ts.map +1 -1
- package/dist/error/error-reporter.js +32 -29
- package/dist/error/error-reporter.js.map +2 -2
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +3 -2
- package/dist/error/index.js.map +2 -2
- package/dist/event/controller/base.d.ts.map +1 -1
- package/dist/event/controller/base.js +2 -1
- package/dist/event/controller/base.js.map +2 -2
- package/dist/event/manager.d.ts.map +1 -1
- package/dist/event/manager.js +5 -4
- package/dist/event/manager.js.map +2 -2
- package/dist/lifecycle/exit.d.ts.map +1 -1
- package/dist/lifecycle/exit.js.map +2 -2
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +3 -2
- package/dist/logger/logger.js.map +2 -2
- package/dist/performance/performance-monitor.d.ts.map +1 -1
- package/dist/performance/performance-monitor.js +10 -3
- package/dist/performance/performance-monitor.js.map +2 -2
- package/dist/queue/processor/base.d.ts.map +1 -1
- package/dist/queue/processor/base.js +2 -1
- package/dist/queue/processor/base.js.map +2 -2
- package/dist/redis/manager.d.ts.map +1 -1
- package/dist/redis/manager.js +3 -2
- package/dist/redis/manager.js.map +2 -2
- package/dist/schemas/common.d.ts +197 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +108 -0
- package/dist/schemas/common.js.map +7 -0
- package/dist/schemas/entity-builder.d.ts +35 -0
- package/dist/schemas/entity-builder.d.ts.map +1 -0
- package/dist/schemas/entity-builder.js +39 -0
- package/dist/schemas/entity-builder.js.map +7 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +7 -0
- package/dist/util/loader.d.ts.map +1 -1
- package/dist/util/loader.js.map +2 -2
- package/dist/webserver/controller/base.d.ts.map +1 -1
- package/dist/webserver/controller/base.js +4 -4
- package/dist/webserver/controller/base.js.map +2 -2
- package/dist/webserver/controller/entity.js +2 -2
- package/dist/webserver/controller/entity.js.map +2 -2
- package/dist/webserver/controller/health.d.ts +0 -2
- package/dist/webserver/controller/health.d.ts.map +1 -1
- package/dist/webserver/controller/health.js +0 -14
- package/dist/webserver/controller/health.js.map +2 -2
- package/dist/webserver/webserver.d.ts.map +1 -1
- package/dist/webserver/webserver.interface.d.ts +2 -2
- package/dist/webserver/webserver.interface.d.ts.map +1 -1
- package/dist/webserver/webserver.interface.js.map +1 -1
- package/dist/webserver/webserver.js +2 -2
- package/dist/webserver/webserver.js.map +2 -2
- package/dist/websocket/index.d.ts +2 -0
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +2 -0
- package/dist/websocket/index.js.map +2 -2
- package/dist/websocket/websocket-auth.d.ts +17 -0
- package/dist/websocket/websocket-auth.d.ts.map +1 -0
- package/dist/websocket/websocket-auth.js +46 -0
- package/dist/websocket/websocket-auth.js.map +7 -0
- package/dist/websocket/websocket-client-manager.d.ts.map +1 -1
- package/dist/websocket/websocket-client-manager.js +6 -5
- package/dist/websocket/websocket-client-manager.js.map +2 -2
- package/dist/websocket/websocket-client.d.ts +29 -0
- package/dist/websocket/websocket-client.d.ts.map +1 -1
- package/dist/websocket/websocket-client.js +97 -3
- package/dist/websocket/websocket-client.js.map +2 -2
- package/dist/websocket/websocket-server.d.ts +10 -0
- package/dist/websocket/websocket-server.d.ts.map +1 -1
- package/dist/websocket/websocket-server.js +40 -52
- package/dist/websocket/websocket-server.js.map +2 -2
- package/dist/websocket/websocket.interface.d.ts +13 -0
- package/dist/websocket/websocket.interface.d.ts.map +1 -1
- package/dist/websocket/websocket.interface.js.map +2 -2
- package/package.json +9 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/error/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorCode, ErrorSeverity } from "./error.interface.js";
|
|
2
|
-
import { ErrorReporter } from "./error-reporter.js";
|
|
2
|
+
import { ErrorReporter, safeSerializeError } from "./error-reporter.js";
|
|
3
3
|
import {
|
|
4
4
|
FrameworkError,
|
|
5
5
|
ConfigurationError,
|
|
@@ -29,6 +29,7 @@ export {
|
|
|
29
29
|
ValidationError,
|
|
30
30
|
WebServerError,
|
|
31
31
|
WebSocketError,
|
|
32
|
-
default2 as errorReporter
|
|
32
|
+
default2 as errorReporter,
|
|
33
|
+
safeSerializeError
|
|
33
34
|
};
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/dist/error/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/error/index.ts"],
|
|
4
|
-
"sourcesContent": ["export type { ErrorEnvelope, ErrorReportOptions } from './error.interface.js';\nexport { ErrorCode, ErrorSeverity } from './error.interface.js';\nexport { ErrorReporter } from './error-reporter.js';\nexport {\n FrameworkError,\n ConfigurationError,\n ValidationError,\n DatabaseError,\n RedisError,\n QueueError,\n WebServerError,\n WebSocketError,\n LifecycleError,\n ResourceNotFoundError,\n NotImplementedError,\n} from './framework-errors.js';\n\n// Export default instance for convenience\nexport { default as errorReporter } from './error-reporter.js';\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,WAAW,qBAAqB;AACzC,SAAS,
|
|
4
|
+
"sourcesContent": ["export type { ErrorEnvelope, ErrorReportOptions } from './error.interface.js';\nexport { ErrorCode, ErrorSeverity } from './error.interface.js';\nexport { ErrorReporter, safeSerializeError } from './error-reporter.js';\nexport {\n FrameworkError,\n ConfigurationError,\n ValidationError,\n DatabaseError,\n RedisError,\n QueueError,\n WebServerError,\n WebSocketError,\n LifecycleError,\n ResourceNotFoundError,\n NotImplementedError,\n} from './framework-errors.js';\n\n// Export default instance for convenience\nexport { default as errorReporter } from './error-reporter.js';\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,WAAW,qBAAqB;AACzC,SAAS,eAAe,0BAA0B;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAoB,WAAXA,gBAAgC;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/event/controller/base.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/event/controller/base.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAGzF,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,mBAAmB;IAC/C,SAAS,CAAC,MAAM,EAAE,OAAO,MAAM,CAAU;IAEzC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAE/C,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAEvC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;gBAExC,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE,gCAAgC;IAUpG;;OAEG;IACI,GAAG;uBACO,KAAK,GAAG,OAAO,YAAY,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;wBAavE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;wBAI7C,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;yBAI5C,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;MAG9D;CACH"}
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import cluster from "cluster";
|
|
4
4
|
import { Logger } from "../../logger/index.js";
|
|
5
|
+
import { safeSerializeError } from "../../error/error-reporter.js";
|
|
5
6
|
class BaseEventController {
|
|
6
7
|
static {
|
|
7
8
|
__name(this, "BaseEventController");
|
|
@@ -26,7 +27,7 @@ class BaseEventController {
|
|
|
26
27
|
if (message) {
|
|
27
28
|
const errorMeta = {
|
|
28
29
|
...meta ?? {},
|
|
29
|
-
error: error instanceof Error ? error.message :
|
|
30
|
+
error: error instanceof Error ? error.message : safeSerializeError(error),
|
|
30
31
|
stack: error instanceof Error ? error.stack : void 0
|
|
31
32
|
};
|
|
32
33
|
this.logger.custom({ level: "event", message, meta: errorMeta });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/event/controller/base.ts"],
|
|
4
|
-
"sourcesContent": ["import cluster from 'cluster';\nimport type { DatabaseInstance } from '../../database/index.js';\nimport type { RedisInstance } from '../../redis/index.js';\nimport type { EventControllerConstructorParams } from './base.interface.js';\nimport { Logger } from '../../logger/index.js';\nimport type { ApplicationConfig } from '../../application/base-application.interface.js';\n\nexport default abstract class BaseEventController {\n protected logger: typeof Logger = Logger;\n\n protected workerId: number | undefined;\n\n protected applicationConfig: ApplicationConfig;\n\n protected redisInstance: RedisInstance;\n // protected queueManager: QueueManager;\n protected databaseInstance: DatabaseInstance | null;\n\n constructor({ applicationConfig, redisInstance, databaseInstance }: EventControllerConstructorParams) {\n this.workerId = cluster.worker?.id;\n\n this.applicationConfig = applicationConfig;\n\n this.redisInstance = redisInstance;\n // this.queueManager = queueManager;\n this.databaseInstance = databaseInstance;\n }\n\n /**\n * Enhanced logger with structured methods\n */\n public log = {\n error: (error: Error | unknown, message?: string, meta?: Record<string, unknown>): void => {\n if (message) {\n const errorMeta = {\n ...(meta ?? {}),\n error: error instanceof Error ? error.message :
|
|
5
|
-
"mappings": ";;AAAA,OAAO,aAAa;AAIpB,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["import cluster from 'cluster';\nimport type { DatabaseInstance } from '../../database/index.js';\nimport type { RedisInstance } from '../../redis/index.js';\nimport type { EventControllerConstructorParams } from './base.interface.js';\nimport { Logger } from '../../logger/index.js';\nimport type { ApplicationConfig } from '../../application/base-application.interface.js';\nimport { safeSerializeError } from '../../error/error-reporter.js';\n\nexport default abstract class BaseEventController {\n protected logger: typeof Logger = Logger;\n\n protected workerId: number | undefined;\n\n protected applicationConfig: ApplicationConfig;\n\n protected redisInstance: RedisInstance;\n // protected queueManager: QueueManager;\n protected databaseInstance: DatabaseInstance | null;\n\n constructor({ applicationConfig, redisInstance, databaseInstance }: EventControllerConstructorParams) {\n this.workerId = cluster.worker?.id;\n\n this.applicationConfig = applicationConfig;\n\n this.redisInstance = redisInstance;\n // this.queueManager = queueManager;\n this.databaseInstance = databaseInstance;\n }\n\n /**\n * Enhanced logger with structured methods\n */\n public log = {\n error: (error: Error | unknown, message?: string, meta?: Record<string, unknown>): void => {\n if (message) {\n const errorMeta = {\n ...(meta ?? {}),\n error: error instanceof Error ? error.message : safeSerializeError(error),\n stack: error instanceof Error ? error.stack : undefined,\n };\n this.logger.custom({ level: 'event', message, meta: errorMeta });\n } else {\n this.logger.custom({ level: 'event', message: error });\n }\n },\n\n info: (message: string, meta?: Record<string, unknown>): void => {\n this.logger.custom({ level: 'event', message, meta });\n },\n\n warn: (message: string, meta?: Record<string, unknown>): void => {\n this.logger.custom({ level: 'event', message, meta });\n },\n\n debug: (message: string, meta?: Record<string, unknown>): void => {\n this.logger.custom({ level: 'event', message, meta });\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,OAAO,aAAa;AAIpB,SAAS,cAAc;AAEvB,SAAS,0BAA0B;AAEnC,MAAO,oBAA2C;AAAA,EARlD,OAQkD;AAAA;AAAA;AAAA,EACtC,SAAwB;AAAA,EAExB;AAAA,EAEA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEV,YAAY,EAAE,mBAAmB,eAAe,iBAAiB,GAAqC;AACpG,SAAK,WAAW,QAAQ,QAAQ;AAEhC,SAAK,oBAAoB;AAEzB,SAAK,gBAAgB;AAErB,SAAK,mBAAmB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKO,MAAM;AAAA,IACX,OAAO,wBAAC,OAAwB,SAAkB,SAAyC;AACzF,UAAI,SAAS;AACX,cAAM,YAAY;AAAA,UAChB,GAAI,QAAQ,CAAC;AAAA,UACb,OAAO,iBAAiB,QAAQ,MAAM,UAAU,mBAAmB,KAAK;AAAA,UACxE,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,QAChD;AACA,aAAK,OAAO,OAAO,EAAE,OAAO,SAAS,SAAS,MAAM,UAAU,CAAC;AAAA,MACjE,OAAO;AACL,aAAK,OAAO,OAAO,EAAE,OAAO,SAAS,SAAS,MAAM,CAAC;AAAA,MACvD;AAAA,IACF,GAXO;AAAA,IAaP,MAAM,wBAAC,SAAiB,SAAyC;AAC/D,WAAK,OAAO,OAAO,EAAE,OAAO,SAAS,SAAS,KAAK,CAAC;AAAA,IACtD,GAFM;AAAA,IAIN,MAAM,wBAAC,SAAiB,SAAyC;AAC/D,WAAK,OAAO,OAAO,EAAE,OAAO,SAAS,SAAS,KAAK,CAAC;AAAA,IACtD,GAFM;AAAA,IAIN,OAAO,wBAAC,SAAiB,SAAyC;AAChE,WAAK,OAAO,OAAO,EAAE,OAAO,SAAS,SAAS,KAAK,CAAC;AAAA,IACtD,GAFO;AAAA,EAGT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/event/manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,6BAA6B,EAE9B,MAAM,wBAAwB,CAAC;AAMhC,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,OAAO,CAAC,MAAM,CAAyB;IAEvC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO,CAAC,gBAAgB,CAA0B;IAElD,OAAO,CAAC,aAAa,CAA4B;gBAErC,MAAM,EAAE,6BAA6B;IAqBpC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/event/manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,6BAA6B,EAE9B,MAAM,wBAAwB,CAAC;AAMhC,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,OAAO,CAAC,MAAM,CAAyB;IAEvC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO,CAAC,gBAAgB,CAA0B;IAElD,OAAO,CAAC,aAAa,CAA4B;gBAErC,MAAM,EAAE,6BAA6B;IAqBpC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmFrB,GAAG,CAAC,QAAQ,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BrG;;OAEG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAGlE"}
|
package/dist/event/manager.js
CHANGED
|
@@ -88,10 +88,11 @@ class EventManager {
|
|
|
88
88
|
Events: registeredEvents.length ? registeredEvents : "-"
|
|
89
89
|
});
|
|
90
90
|
if (this.options.debug?.printEvents) {
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
this.logger.custom({
|
|
92
|
+
level: "event",
|
|
93
|
+
message: `Registered Events:
|
|
94
|
+
${registeredEvents.map((e) => `- ${e}`).join("\n")}`
|
|
95
|
+
});
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
async run({ name, data }) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/event/manager.ts"],
|
|
4
|
-
"sourcesContent": ["// event-manager.ts\nimport { Logger } from '../logger/index.js';\nimport { File, Helper, Loader } from '../util/index.js';\nimport type {\n EventDefinition,\n EventHandler,\n EventManagerConstructorParams,\n EventManagerOptions,\n} from './manager.interface.js';\nimport type { ApplicationConfig } from '../application/base-application.interface.js';\nimport type DatabaseInstance from '../database/instance.js';\nimport type { RedisInstance } from '../redis/index.js';\nimport type { EventControllerType } from './controller/base.interface.js';\n\nexport default class EventManager {\n private logger: typeof Logger = Logger;\n\n private applicationConfig: ApplicationConfig;\n private options: EventManagerOptions;\n private events: EventDefinition[];\n private redisInstance: RedisInstance;\n // private queueManager: QueueManager;\n private databaseInstance: DatabaseInstance | null;\n\n private eventHandlers: Map<string, EventHandler>;\n\n constructor(params: EventManagerConstructorParams) {\n const defaultOptions: Partial<EventManagerOptions> = {\n log: {\n startUp: true,\n },\n debug: {\n printEvents: false,\n },\n };\n\n this.options = Helper.defaultsDeep(params.options, defaultOptions);\n\n this.applicationConfig = params.applicationConfig;\n this.events = params.events;\n this.redisInstance = params.redisInstance;\n // this.queueManager = params.queueManager;\n this.databaseInstance = params.databaseInstance;\n\n this.eventHandlers = new Map();\n }\n\n public async load(): Promise<void> {\n // Check if controllers directory exists\n const controllersDirectoryExists = await File.pathExists(this.options.controllersDirectory);\n\n if (!controllersDirectoryExists) {\n return;\n }\n\n // Load controllers\n const controllers = await Loader.loadModulesInDirectory({\n directory: this.options.controllersDirectory,\n extensions: ['.ts', '.js'],\n });\n\n // Load event handlers\n for (const event of this.events) {\n let ControllerClass: EventControllerType;\n let controllerName: string;\n\n if (event.controller) {\n ControllerClass = event.controller;\n controllerName = ControllerClass.name;\n } else if (event.controllerName) {\n ControllerClass = controllers[event.controllerName] as EventControllerType;\n controllerName = event.controllerName;\n } else {\n throw new Error('Event controller not specified');\n }\n\n if (typeof ControllerClass !== 'function') {\n const controllerPath = `${this.options.controllersDirectory}/${event.controllerName}.ts`;\n this.logger.warn({\n message: 'Event controller not found',\n meta: {\n Controller: event.controllerName,\n Path: controllerPath,\n Event: event.name,\n },\n });\n continue;\n }\n\n // Initialize controller instance\n const controllerInstance = new ControllerClass({\n applicationConfig: this.applicationConfig,\n redisInstance: this.redisInstance,\n // queueManager: this.queueManager,\n databaseInstance: this.databaseInstance,\n });\n\n const handler = controllerInstance[event.handlerName as keyof typeof controllerInstance];\n\n if (!handler || typeof handler !== 'function') {\n this.logger.warn({\n message: 'Event handler not found',\n meta: {\n Controller: controllerName,\n Handler: event.handlerName,\n Event: event.name,\n },\n });\n continue;\n }\n\n // Store the handler\n this.eventHandlers.set(event.name, (handler as EventHandler).bind(controllerInstance));\n }\n\n // Log the list of registered events\n const registeredEvents = Array.from(this.eventHandlers.keys());\n\n this.log('Registered Events:', {\n Events: registeredEvents.length ? registeredEvents : '-',\n });\n\n if (this.options.debug?.printEvents) {\n this.
|
|
5
|
-
"mappings": ";;AACA,SAAS,cAAc;AACvB,SAAS,MAAM,QAAQ,cAAc;AAYrC,MAAO,aAA2B;AAAA,EAdlC,OAckC;AAAA;AAAA;AAAA,EACxB,SAAwB;AAAA,EAExB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EAEA;AAAA,EAER,YAAY,QAAuC;AACjD,UAAM,iBAA+C;AAAA,MACnD,KAAK;AAAA,QACH,SAAS;AAAA,MACX;AAAA,MACA,OAAO;AAAA,QACL,aAAa;AAAA,MACf;AAAA,IACF;AAEA,SAAK,UAAU,OAAO,aAAa,OAAO,SAAS,cAAc;AAEjE,SAAK,oBAAoB,OAAO;AAChC,SAAK,SAAS,OAAO;AACrB,SAAK,gBAAgB,OAAO;AAE5B,SAAK,mBAAmB,OAAO;AAE/B,SAAK,gBAAgB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EAEA,MAAa,OAAsB;AAEjC,UAAM,6BAA6B,MAAM,KAAK,WAAW,KAAK,QAAQ,oBAAoB;AAE1F,QAAI,CAAC,4BAA4B;AAC/B;AAAA,IACF;AAGA,UAAM,cAAc,MAAM,OAAO,uBAAuB;AAAA,MACtD,WAAW,KAAK,QAAQ;AAA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a;AACnC,WAAK,
|
|
4
|
+
"sourcesContent": ["// event-manager.ts\nimport { Logger } from '../logger/index.js';\nimport { File, Helper, Loader } from '../util/index.js';\nimport type {\n EventDefinition,\n EventHandler,\n EventManagerConstructorParams,\n EventManagerOptions,\n} from './manager.interface.js';\nimport type { ApplicationConfig } from '../application/base-application.interface.js';\nimport type DatabaseInstance from '../database/instance.js';\nimport type { RedisInstance } from '../redis/index.js';\nimport type { EventControllerType } from './controller/base.interface.js';\n\nexport default class EventManager {\n private logger: typeof Logger = Logger;\n\n private applicationConfig: ApplicationConfig;\n private options: EventManagerOptions;\n private events: EventDefinition[];\n private redisInstance: RedisInstance;\n // private queueManager: QueueManager;\n private databaseInstance: DatabaseInstance | null;\n\n private eventHandlers: Map<string, EventHandler>;\n\n constructor(params: EventManagerConstructorParams) {\n const defaultOptions: Partial<EventManagerOptions> = {\n log: {\n startUp: true,\n },\n debug: {\n printEvents: false,\n },\n };\n\n this.options = Helper.defaultsDeep(params.options, defaultOptions);\n\n this.applicationConfig = params.applicationConfig;\n this.events = params.events;\n this.redisInstance = params.redisInstance;\n // this.queueManager = params.queueManager;\n this.databaseInstance = params.databaseInstance;\n\n this.eventHandlers = new Map();\n }\n\n public async load(): Promise<void> {\n // Check if controllers directory exists\n const controllersDirectoryExists = await File.pathExists(this.options.controllersDirectory);\n\n if (!controllersDirectoryExists) {\n return;\n }\n\n // Load controllers\n const controllers = await Loader.loadModulesInDirectory({\n directory: this.options.controllersDirectory,\n extensions: ['.ts', '.js'],\n });\n\n // Load event handlers\n for (const event of this.events) {\n let ControllerClass: EventControllerType;\n let controllerName: string;\n\n if (event.controller) {\n ControllerClass = event.controller;\n controllerName = ControllerClass.name;\n } else if (event.controllerName) {\n ControllerClass = controllers[event.controllerName] as EventControllerType;\n controllerName = event.controllerName;\n } else {\n throw new Error('Event controller not specified');\n }\n\n if (typeof ControllerClass !== 'function') {\n const controllerPath = `${this.options.controllersDirectory}/${event.controllerName}.ts`;\n this.logger.warn({\n message: 'Event controller not found',\n meta: {\n Controller: event.controllerName,\n Path: controllerPath,\n Event: event.name,\n },\n });\n continue;\n }\n\n // Initialize controller instance\n const controllerInstance = new ControllerClass({\n applicationConfig: this.applicationConfig,\n redisInstance: this.redisInstance,\n // queueManager: this.queueManager,\n databaseInstance: this.databaseInstance,\n });\n\n const handler = controllerInstance[event.handlerName as keyof typeof controllerInstance];\n\n if (!handler || typeof handler !== 'function') {\n this.logger.warn({\n message: 'Event handler not found',\n meta: {\n Controller: controllerName,\n Handler: event.handlerName,\n Event: event.name,\n },\n });\n continue;\n }\n\n // Store the handler\n this.eventHandlers.set(event.name, (handler as EventHandler).bind(controllerInstance));\n }\n\n // Log the list of registered events\n const registeredEvents = Array.from(this.eventHandlers.keys());\n\n this.log('Registered Events:', {\n Events: registeredEvents.length ? registeredEvents : '-',\n });\n\n if (this.options.debug?.printEvents) {\n this.logger.custom({\n level: 'event',\n message: `Registered Events:\\n${registeredEvents.map(e => `- ${e}`).join('\\n')}`,\n });\n }\n }\n\n public async run<TPayload = unknown>({ name, data }: { name: string; data: TPayload }): Promise<void> {\n try {\n const handler = this.eventHandlers.get(name);\n\n if (!handler) {\n const availableEvents = Array.from(this.eventHandlers.keys()).join(', ');\n\n this.logger.warn({\n message: 'Event handler not found for event',\n meta: {\n Event: name,\n AvailableEvents: availableEvents,\n },\n });\n\n throw new Error(`Event handler not found for event '${name}'. Available events are: ${availableEvents}`);\n }\n\n await handler(data);\n\n this.log('Event executed', { Event: name });\n } catch (error) {\n this.logger.error({ error });\n }\n }\n\n /**\n * Log event message\n */\n public log(message: string, meta?: Record<string, unknown>): void {\n this.logger.custom({ level: 'event', message, meta });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AACA,SAAS,cAAc;AACvB,SAAS,MAAM,QAAQ,cAAc;AAYrC,MAAO,aAA2B;AAAA,EAdlC,OAckC;AAAA;AAAA;AAAA,EACxB,SAAwB;AAAA,EAExB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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AAA,IAC5C,SAAS,OAAO;AACd,WAAK,OAAO,MAAM,EAAE,MAAM,CAAC;AAAA,IAC7B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKO,IAAI,SAAiB,MAAsC;AAChE,SAAK,OAAO,OAAO,EAAE,OAAO,SAAS,SAAS,KAAK,CAAC;AAAA,EACtD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/lifecycle/exit.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,KAAK,WAAW,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;AAMlD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,QAE/C;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/lifecycle/exit.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,KAAK,WAAW,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;AAMlD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,QAE/C;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,QAuB/C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lifecycle/exit.ts"],
|
|
4
|
-
"sourcesContent": ["export type ExitCode = 0 | 1 | 2 | 130 | 137 | 143;\n\nexport interface ExitOutcome {\n code: ExitCode;\n reason: string;\n error?: unknown;\n}\n\ntype ExitHandler = (outcome: ExitOutcome) => void;\n\nlet handler: ExitHandler = outcome => {\n process.exit(outcome.code);\n};\n\nexport function setExitHandler(next: ExitHandler) {\n handler = next;\n}\n\nexport function requestExit(outcome: ExitOutcome) {\n const nodeEnv = process.env.NODE_ENV ?? '';\n const isTestEnv =\n nodeEnv.toLowerCase() === 'test' ||\n 'VITEST' in process.env ||\n 'VITEST_WORKER_ID' in process.env ||\n process.argv.some(a => a.includes('vitest')) ||\n typeof (globalThis as any).afterAll === 'function';\n\n if (isTestEnv) {\n // Suppress real process exit during tests; vitest intercepts and would throw otherwise.\n console.info(`[exit] (test env) code=${outcome.code} reason=${outcome.reason}`);\n return;\n }\n\n try {\n handler(outcome);\n } catch (err) {\n console.error('Exit handler failure', err);\n process.exit(outcome.code);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAUA,IAAI,UAAuB,oCAAW;AACpC,UAAQ,KAAK,QAAQ,IAAI;AAC3B,GAF2B;AAIpB,SAAS,eAAe,MAAmB;AAChD,YAAU;AACZ;AAFgB;AAIT,SAAS,YAAY,SAAsB;AAChD,QAAM,UAAU,QAAQ,IAAI,YAAY;AACxC,QAAM,YACJ,QAAQ,YAAY,MAAM,UAC1B,YAAY,QAAQ,OACpB,sBAAsB,QAAQ,OAC9B,QAAQ,KAAK,KAAK,OAAK,EAAE,SAAS,QAAQ,CAAC,KAC3C,OAAQ,WAAmB,aAAa;AAE1C,MAAI,WAAW;
|
|
4
|
+
"sourcesContent": ["export type ExitCode = 0 | 1 | 2 | 130 | 137 | 143;\n\nexport interface ExitOutcome {\n code: ExitCode;\n reason: string;\n error?: unknown;\n}\n\ntype ExitHandler = (outcome: ExitOutcome) => void;\n\nlet handler: ExitHandler = outcome => {\n process.exit(outcome.code);\n};\n\nexport function setExitHandler(next: ExitHandler) {\n handler = next;\n}\n\nexport function requestExit(outcome: ExitOutcome) {\n const nodeEnv = process.env.NODE_ENV ?? '';\n const isTestEnv =\n nodeEnv.toLowerCase() === 'test' ||\n 'VITEST' in process.env ||\n 'VITEST_WORKER_ID' in process.env ||\n process.argv.some(a => a.includes('vitest')) ||\n typeof (globalThis as any).afterAll === 'function';\n\n if (isTestEnv) {\n // Suppress real process exit during tests; vitest intercepts and would throw otherwise.\n // Note: Using console here intentionally as Logger may not be available during test teardown\n console.info(`[exit] (test env) code=${outcome.code} reason=${outcome.reason}`);\n return;\n }\n\n try {\n handler(outcome);\n } catch (err) {\n // Note: Using console here intentionally as this is a critical failure path\n console.error('Exit handler failure', err);\n process.exit(outcome.code);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAUA,IAAI,UAAuB,oCAAW;AACpC,UAAQ,KAAK,QAAQ,IAAI;AAC3B,GAF2B;AAIpB,SAAS,eAAe,MAAmB;AAChD,YAAU;AACZ;AAFgB;AAIT,SAAS,YAAY,SAAsB;AAChD,QAAM,UAAU,QAAQ,IAAI,YAAY;AACxC,QAAM,YACJ,QAAQ,YAAY,MAAM,UAC1B,YAAY,QAAQ,OACpB,sBAAsB,QAAQ,OAC9B,QAAQ,KAAK,KAAK,OAAK,EAAE,SAAS,QAAQ,CAAC,KAC3C,OAAQ,WAAmB,aAAa;AAE1C,MAAI,WAAW;AAGb,YAAQ,KAAK,0BAA0B,QAAQ,IAAI,WAAW,QAAQ,MAAM,EAAE;AAC9E;AAAA,EACF;AAEA,MAAI;AACF,YAAQ,OAAO;AAAA,EACjB,SAAS,KAAK;AAEZ,YAAQ,MAAM,wBAAwB,GAAG;AACzC,YAAQ,KAAK,QAAQ,IAAI;AAAA,EAC3B;AACF;AAvBgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,UAAU,GACV,OAAO,GACP,WAAW,GACX,WAAW,GACX,OAAO,GACP,UAAU,GACV,OAAO,GACP,OAAO,CAAC;AAEZ,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAO,CAAC,MAAM,CAAiB;IAE/B,OAAO,CAAC,WAAW,CAAqB;IAEjC,mBAAmB,UAAS;IAEnC,OAAO,CAAC,sBAAsB,CAAQ;IAEtC,OAAO;WAwDO,WAAW,IAAI,MAAM;IAQnC,OAAO,CAAC,eAAe;IAuDhB,SAAS,CAAC,EAAE,sBAAsB,EAAE,EAAE;QAAE,sBAAsB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAMjF,UAAU,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAiBxF,GAAG,CAAC,EACT,KAAK,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EAAE,QAAQ,GAClB,EAAE;QACD,KAAK,EAAE,YAAY,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,UAAU,CAAC;KACtB,GAAG,IAAI;IAcD,KAAK,CAAC,EAC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AO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IA2D3G,MAAM,CAAC,EACZ,KAAK,EACL,OAAO,EACP,IAAI,EACJ,OAAO,GACR,EAAE;QACD,KAAK,EAAE,YAAY,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,UAAU,CAAC;KACtB,GAAG,IAAI;CAGT;;AAED,wBAAoC"}
|
package/dist/logger/logger.js
CHANGED
|
@@ -5,6 +5,7 @@ import { nodeProfilingIntegration } from "@sentry/profiling-node";
|
|
|
5
5
|
import cluster from "node:cluster";
|
|
6
6
|
import winston from "winston";
|
|
7
7
|
import { getRequestId } from "../request-context/index.js";
|
|
8
|
+
import { safeSerializeError } from "../error/error-reporter.js";
|
|
8
9
|
class Logger {
|
|
9
10
|
static {
|
|
10
11
|
__name(this, "Logger");
|
|
@@ -191,7 +192,7 @@ class Logger {
|
|
|
191
192
|
options: objOptions
|
|
192
193
|
} = arg1;
|
|
193
194
|
if (objMessage) {
|
|
194
|
-
const errorMessage = error instanceof Error ? error.message :
|
|
195
|
+
const errorMessage = error instanceof Error ? error.message : safeSerializeError(error);
|
|
195
196
|
const combinedMessage = `${objMessage}: ${errorMessage}`;
|
|
196
197
|
this.log({ level: "error", message: combinedMessage, meta: objMeta, options: objOptions });
|
|
197
198
|
if (error instanceof Error && this.isSentryInitialized) {
|
|
@@ -207,7 +208,7 @@ class Logger {
|
|
|
207
208
|
}
|
|
208
209
|
const errorObj = arg1;
|
|
209
210
|
if (message) {
|
|
210
|
-
const errorMessage = errorObj instanceof Error ? errorObj.message :
|
|
211
|
+
const errorMessage = errorObj instanceof Error ? errorObj.message : safeSerializeError(errorObj);
|
|
211
212
|
const combinedMessage = `${message}: ${errorMessage}`;
|
|
212
213
|
this.log({ level: "error", message: combinedMessage, meta, options });
|
|
213
214
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/logger/logger.ts"],
|
|
4
|
-
"sourcesContent": ["import * as Sentry from '@sentry/node';\nimport { nodeProfilingIntegration } from '@sentry/profiling-node';\nimport cluster from 'node:cluster';\nimport winston from 'winston';\nimport type { LogOptions } from '../websocket/utils.js';\nimport { getRequestId } from '../request-context/index.js';\n\nexport type LoggerLevels =\n | 'error'\n | 'warn'\n | 'info'\n | 'command'\n | 'database'\n | 'redis'\n | 'webServer'\n | 'webSocket'\n | 'queue'\n | 'queueJob'\n | 'event'\n | 'debug';\n\nexport class Logger {\n private static instance: Logger;\n private logger: winston.Logger;\n\n private environment: string | undefined;\n\n public isSentryInitialized = false;\n\n private showRequestIdInConsole = true; // Default to true for backward compatibility\n\n private constructor() {\n this.environment = process.env.NODE_ENV;\n\n const customFormat = this.getCustomFormat();\n\n const customLevels: winston.config.AbstractConfigSetLevels = {\n error: 0,\n warn: 1,\n info: 2,\n command: 3,\n database: 4,\n redis: 5,\n webServer: 6,\n webSocket: 7,\n queue: 8,\n queueJob: 9,\n event: 10,\n debug: 11,\n };\n\n const customColors: winston.config.AbstractConfigSetColors = {\n error: 'red',\n warn: 'yellow',\n info: 'blue',\n command: 'cyan',\n database: 'brightGreen',\n redis: 'brightYellow',\n webServer: 'brightBlue',\n webSocket: 'brightMagenta',\n queue: 'gray',\n queueJob: 'blue',\n event: 'brightGreen',\n debug: 'brightCyan',\n };\n\n winston.addColors(customColors);\n\n this.logger = winston.createLogger({\n levels: customLevels,\n level: this.environment === 'production' ? 'info' : 'debug',\n format: winston.format.combine(\n winston.format.timestamp({\n format: 'YYYY-MM-DD HH:mm:ss',\n }),\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n winston.format.json(),\n ),\n transports: [\n new winston.transports.Console({\n format: winston.format.combine(winston.format.colorize(), customFormat),\n }),\n ],\n });\n }\n\n public static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n\n return Logger.instance;\n }\n\n private getCustomFormat(): winston.Logform.Format {\n return winston.format.printf(({ level, message, timestamp, ...meta }) => {\n // Auto-inject request ID from AsyncLocalStorage context if available\n const requestId = getRequestId();\n if (requestId && !meta['requestId'] && this.showRequestIdInConsole) {\n meta['requestId'] = requestId;\n }\n\n if (cluster.isWorker && cluster.worker) {\n meta['Worker'] = cluster.worker.id; // .process.pid;\n }\n\n const metaString = Object.entries(meta)\n .map(([key, value]) => {\n // Safely convert value to string representation\n let stringValue: string;\n\n if (value === null) {\n stringValue = 'null';\n } else if (value === undefined) {\n stringValue = 'undefined';\n } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n stringValue = String(value);\n } else if (value instanceof Error) {\n stringValue = value.message;\n } else if (value instanceof Promise) {\n stringValue = '[Promise]';\n } else if (typeof value === 'object') {\n try {\n // Attempt to JSON.stringify, but handle circular references\n stringValue = JSON.stringify(value);\n } catch {\n // Fallback for circular references or other issues\n stringValue = '[Object]';\n }\n } else {\n stringValue = String(value);\n }\n\n return `${key}: ${stringValue}`;\n })\n .join(' | ');\n\n if (level === 'error') {\n if (this.isSentryInitialized) {\n const errorMessage = typeof message === 'string' ? message : JSON.stringify(message);\n\n Sentry.captureException(new Error(errorMessage));\n }\n }\n\n return `[${timestamp}] ${level}: ${message}${metaString ? ` (${metaString})` : ''}`;\n });\n }\n\n public configure({ showRequestIdInConsole }: { showRequestIdInConsole?: boolean }): void {\n if (showRequestIdInConsole !== undefined) {\n this.showRequestIdInConsole = showRequestIdInConsole;\n }\n }\n\n public initSentry({ sentryDsn, environment }: { sentryDsn: string; environment: string }): void {\n if (!sentryDsn) {\n this.logger.warn('Missing Sentry DSN when initializing Sentry');\n\n return;\n }\n\n Sentry.init({\n dsn: sentryDsn,\n integrations: [nodeProfilingIntegration()],\n tracesSampleRate: 1.0,\n environment,\n });\n\n this.isSentryInitialized = true;\n }\n\n public log({\n level,\n message,\n meta,\n options: _options,\n }: {\n level: LoggerLevels;\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void {\n // if (options?.muteWorker) {\n // }\n\n if (message instanceof Error) {\n const errorMessage = message.stack ?? message.toString();\n this.logger.log(level, errorMessage, meta);\n } else if (typeof message === 'string') {\n this.logger.log(level, message, meta);\n } else {\n this.logger.log(level, JSON.stringify(message), meta);\n }\n }\n\n public debug({\n message,\n meta,\n options,\n }: {\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n public debug(message: unknown, meta?: Record<string, unknown>): void;\n public debug(\n messageOrOptions: unknown | { message: unknown; meta?: Record<string, unknown>; options?: LogOptions },\n meta?: Record<string, unknown>,\n ): void {\n if (typeof messageOrOptions === 'object' && messageOrOptions !== null && 'message' in messageOrOptions) {\n const {\n message,\n meta: optionsMeta,\n options,\n } = messageOrOptions as { message: unknown; meta?: Record<string, unknown>; options?: LogOptions };\n this.log({ level: 'debug', message, meta: optionsMeta, options });\n } else {\n this.log({ level: 'debug', message: messageOrOptions, meta, options: undefined });\n }\n }\n\n public info({\n message,\n meta,\n options,\n }: {\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n public info(message: unknown, meta?: Record<string, unknown>): void;\n public info(\n messageOrOptions: unknown | { message: unknown; meta?: Record<string, unknown>; options?: LogOptions },\n meta?: Record<string, unknown>,\n ): void {\n if (typeof messageOrOptions === 'object' && messageOrOptions !== null && 'message' in messageOrOptions) {\n const {\n message,\n meta: optionsMeta,\n options,\n } = messageOrOptions as { message: unknown; meta?: Record<string, unknown>; options?: LogOptions };\n this.log({ level: 'info', message, meta: optionsMeta, options });\n } else {\n this.log({ level: 'info', message: messageOrOptions, meta, options: undefined });\n }\n }\n\n public warn({\n message,\n meta,\n options,\n }: {\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n public warn(message: unknown, meta?: Record<string, unknown>): void;\n public warn(\n messageOrOptions: unknown | { message: unknown; meta?: Record<string, unknown>; options?: LogOptions },\n meta?: Record<string, unknown>,\n ): void {\n if (typeof messageOrOptions === 'object' && messageOrOptions !== null && 'message' in messageOrOptions) {\n const {\n message,\n meta: optionsMeta,\n options,\n } = messageOrOptions as { message: unknown; meta?: Record<string, unknown>; options?: LogOptions };\n this.log({ level: 'warn', message, meta: optionsMeta, options });\n } else {\n this.log({ level: 'warn', message: messageOrOptions, meta, options: undefined });\n }\n }\n\n // Overload 1: Object signature (existing usage)\n public error(args: {\n error: Error | unknown;\n message?: string;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n // Overload 2: Positional signature (new usage)\n public error(error: Error | unknown, message?: string, meta?: Record<string, unknown>, options?: LogOptions): void;\n public error(\n arg1:\n | { error: Error | unknown; message?: string; meta?: Record<string, unknown>; options?: LogOptions }\n | (Error | unknown),\n message?: string,\n meta?: Record<string, unknown>,\n options?: LogOptions,\n ): void {\n // Support original object signature: Logger.error({ error, message?, meta?, options? })\n if (\n typeof arg1 === 'object' &&\n arg1 !== null &&\n 'error' in arg1 &&\n // If the caller passed a second positional arg, treat it as new signature\n message === undefined\n ) {\n const {\n error,\n message: objMessage,\n meta: objMeta,\n options: objOptions,\n } = arg1 as {\n error: Error | unknown;\n message?: string;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n };\n\n if (objMessage) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n const combinedMessage = `${objMessage}: ${errorMessage}`;\n this.log({ level: 'error', message: combinedMessage, meta: objMeta, options: objOptions });\n if (error instanceof Error && this.isSentryInitialized) {\n Sentry.captureException(error);\n }\n } else {\n this.log({ level: 'error', message: error, meta: objMeta, options: objOptions });\n if (error instanceof Error && this.isSentryInitialized) {\n Sentry.captureException(error);\n }\n }\n return;\n }\n\n // New positional signature: Logger.error(error, message?, meta?, options?)\n const errorObj = arg1;\n if (message) {\n const errorMessage = errorObj instanceof Error ? errorObj.message : String(errorObj);\n const combinedMessage = `${message}: ${errorMessage}`;\n this.log({ level: 'error', message: combinedMessage, meta, options });\n } else {\n this.log({ level: 'error', message: errorObj, meta, options });\n }\n if (errorObj instanceof Error && this.isSentryInitialized) {\n Sentry.captureException(errorObj);\n }\n }\n\n public custom({\n level,\n message,\n meta,\n options,\n }: {\n level: LoggerLevels;\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void {\n this.log({ level, message, meta, options });\n }\n}\n\nexport default Logger.getInstance();\n"],
|
|
5
|
-
"mappings": ";;AAAA,YAAY,YAAY;AACxB,SAAS,gCAAgC;AACzC,OAAO,aAAa;AACpB,OAAO,aAAa;AAEpB,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import * as Sentry from '@sentry/node';\nimport { nodeProfilingIntegration } from '@sentry/profiling-node';\nimport cluster from 'node:cluster';\nimport winston from 'winston';\nimport type { LogOptions } from '../websocket/utils.js';\nimport { getRequestId } from '../request-context/index.js';\nimport { safeSerializeError } from '../error/error-reporter.js';\n\nexport type LoggerLevels =\n | 'error'\n | 'warn'\n | 'info'\n | 'command'\n | 'database'\n | 'redis'\n | 'webServer'\n | 'webSocket'\n | 'queue'\n | 'queueJob'\n | 'event'\n | 'debug';\n\nexport class Logger {\n private static instance: Logger;\n private logger: winston.Logger;\n\n private environment: string | undefined;\n\n public isSentryInitialized = false;\n\n private showRequestIdInConsole = true; // Default to true for backward compatibility\n\n private constructor() {\n this.environment = process.env.NODE_ENV;\n\n const customFormat = this.getCustomFormat();\n\n const customLevels: winston.config.AbstractConfigSetLevels = {\n error: 0,\n warn: 1,\n info: 2,\n command: 3,\n database: 4,\n redis: 5,\n webServer: 6,\n webSocket: 7,\n queue: 8,\n queueJob: 9,\n event: 10,\n debug: 11,\n };\n\n const customColors: winston.config.AbstractConfigSetColors = {\n error: 'red',\n warn: 'yellow',\n info: 'blue',\n command: 'cyan',\n database: 'brightGreen',\n redis: 'brightYellow',\n webServer: 'brightBlue',\n webSocket: 'brightMagenta',\n queue: 'gray',\n queueJob: 'blue',\n event: 'brightGreen',\n debug: 'brightCyan',\n };\n\n winston.addColors(customColors);\n\n this.logger = winston.createLogger({\n levels: customLevels,\n level: this.environment === 'production' ? 'info' : 'debug',\n format: winston.format.combine(\n winston.format.timestamp({\n format: 'YYYY-MM-DD HH:mm:ss',\n }),\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n winston.format.json(),\n ),\n transports: [\n new winston.transports.Console({\n format: winston.format.combine(winston.format.colorize(), customFormat),\n }),\n ],\n });\n }\n\n public static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n\n return Logger.instance;\n }\n\n private getCustomFormat(): winston.Logform.Format {\n return winston.format.printf(({ level, message, timestamp, ...meta }) => {\n // Auto-inject request ID from AsyncLocalStorage context if available\n const requestId = getRequestId();\n if (requestId && !meta['requestId'] && this.showRequestIdInConsole) {\n meta['requestId'] = requestId;\n }\n\n if (cluster.isWorker && cluster.worker) {\n meta['Worker'] = cluster.worker.id; // .process.pid;\n }\n\n const metaString = Object.entries(meta)\n .map(([key, value]) => {\n // Safely convert value to string representation\n let stringValue: string;\n\n if (value === null) {\n stringValue = 'null';\n } else if (value === undefined) {\n stringValue = 'undefined';\n } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n stringValue = String(value);\n } else if (value instanceof Error) {\n stringValue = value.message;\n } else if (value instanceof Promise) {\n stringValue = '[Promise]';\n } else if (typeof value === 'object') {\n try {\n // Attempt to JSON.stringify, but handle circular references\n stringValue = JSON.stringify(value);\n } catch {\n // Fallback for circular references or other issues\n stringValue = '[Object]';\n }\n } else {\n stringValue = String(value);\n }\n\n return `${key}: ${stringValue}`;\n })\n .join(' | ');\n\n if (level === 'error') {\n if (this.isSentryInitialized) {\n const errorMessage = typeof message === 'string' ? message : JSON.stringify(message);\n\n Sentry.captureException(new Error(errorMessage));\n }\n }\n\n return `[${timestamp}] ${level}: ${message}${metaString ? ` (${metaString})` : ''}`;\n });\n }\n\n public configure({ showRequestIdInConsole }: { showRequestIdInConsole?: boolean }): void {\n if (showRequestIdInConsole !== undefined) {\n this.showRequestIdInConsole = showRequestIdInConsole;\n }\n }\n\n public initSentry({ sentryDsn, environment }: { sentryDsn: string; environment: string }): void {\n if (!sentryDsn) {\n this.logger.warn('Missing Sentry DSN when initializing Sentry');\n\n return;\n }\n\n Sentry.init({\n dsn: sentryDsn,\n integrations: [nodeProfilingIntegration()],\n tracesSampleRate: 1.0,\n environment,\n });\n\n this.isSentryInitialized = true;\n }\n\n public log({\n level,\n message,\n meta,\n options: _options,\n }: {\n level: LoggerLevels;\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void {\n // if (options?.muteWorker) {\n // }\n\n if (message instanceof Error) {\n const errorMessage = message.stack ?? message.toString();\n this.logger.log(level, errorMessage, meta);\n } else if (typeof message === 'string') {\n this.logger.log(level, message, meta);\n } else {\n this.logger.log(level, JSON.stringify(message), meta);\n }\n }\n\n public debug({\n message,\n meta,\n options,\n }: {\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n public debug(message: unknown, meta?: Record<string, unknown>): void;\n public debug(\n messageOrOptions: unknown | { message: unknown; meta?: Record<string, unknown>; options?: LogOptions },\n meta?: Record<string, unknown>,\n ): void {\n if (typeof messageOrOptions === 'object' && messageOrOptions !== null && 'message' in messageOrOptions) {\n const {\n message,\n meta: optionsMeta,\n options,\n } = messageOrOptions as { message: unknown; meta?: Record<string, unknown>; options?: LogOptions };\n this.log({ level: 'debug', message, meta: optionsMeta, options });\n } else {\n this.log({ level: 'debug', message: messageOrOptions, meta, options: undefined });\n }\n }\n\n public info({\n message,\n meta,\n options,\n }: {\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n public info(message: unknown, meta?: Record<string, unknown>): void;\n public info(\n messageOrOptions: unknown | { message: unknown; meta?: Record<string, unknown>; options?: LogOptions },\n meta?: Record<string, unknown>,\n ): void {\n if (typeof messageOrOptions === 'object' && messageOrOptions !== null && 'message' in messageOrOptions) {\n const {\n message,\n meta: optionsMeta,\n options,\n } = messageOrOptions as { message: unknown; meta?: Record<string, unknown>; options?: LogOptions };\n this.log({ level: 'info', message, meta: optionsMeta, options });\n } else {\n this.log({ level: 'info', message: messageOrOptions, meta, options: undefined });\n }\n }\n\n public warn({\n message,\n meta,\n options,\n }: {\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n public warn(message: unknown, meta?: Record<string, unknown>): void;\n public warn(\n messageOrOptions: unknown | { message: unknown; meta?: Record<string, unknown>; options?: LogOptions },\n meta?: Record<string, unknown>,\n ): void {\n if (typeof messageOrOptions === 'object' && messageOrOptions !== null && 'message' in messageOrOptions) {\n const {\n message,\n meta: optionsMeta,\n options,\n } = messageOrOptions as { message: unknown; meta?: Record<string, unknown>; options?: LogOptions };\n this.log({ level: 'warn', message, meta: optionsMeta, options });\n } else {\n this.log({ level: 'warn', message: messageOrOptions, meta, options: undefined });\n }\n }\n\n // Overload 1: Object signature (existing usage)\n public error(args: {\n error: Error | unknown;\n message?: string;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void;\n // Overload 2: Positional signature (new usage)\n public error(error: Error | unknown, message?: string, meta?: Record<string, unknown>, options?: LogOptions): void;\n public error(\n arg1:\n | { error: Error | unknown; message?: string; meta?: Record<string, unknown>; options?: LogOptions }\n | (Error | unknown),\n message?: string,\n meta?: Record<string, unknown>,\n options?: LogOptions,\n ): void {\n // Support original object signature: Logger.error({ error, message?, meta?, options? })\n if (\n typeof arg1 === 'object' &&\n arg1 !== null &&\n 'error' in arg1 &&\n // If the caller passed a second positional arg, treat it as new signature\n message === undefined\n ) {\n const {\n error,\n message: objMessage,\n meta: objMeta,\n options: objOptions,\n } = arg1 as {\n error: Error | unknown;\n message?: string;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n };\n\n if (objMessage) {\n const errorMessage = error instanceof Error ? error.message : safeSerializeError(error);\n const combinedMessage = `${objMessage}: ${errorMessage}`;\n this.log({ level: 'error', message: combinedMessage, meta: objMeta, options: objOptions });\n if (error instanceof Error && this.isSentryInitialized) {\n Sentry.captureException(error);\n }\n } else {\n this.log({ level: 'error', message: error, meta: objMeta, options: objOptions });\n if (error instanceof Error && this.isSentryInitialized) {\n Sentry.captureException(error);\n }\n }\n return;\n }\n\n // New positional signature: Logger.error(error, message?, meta?, options?)\n const errorObj = arg1;\n if (message) {\n const errorMessage = errorObj instanceof Error ? errorObj.message : safeSerializeError(errorObj);\n const combinedMessage = `${message}: ${errorMessage}`;\n this.log({ level: 'error', message: combinedMessage, meta, options });\n } else {\n this.log({ level: 'error', message: errorObj, meta, options });\n }\n if (errorObj instanceof Error && this.isSentryInitialized) {\n Sentry.captureException(errorObj);\n }\n }\n\n public custom({\n level,\n message,\n meta,\n options,\n }: {\n level: LoggerLevels;\n message: unknown;\n meta?: Record<string, unknown>;\n options?: LogOptions;\n }): void {\n this.log({ level, message, meta, options });\n }\n}\n\nexport default Logger.getInstance();\n"],
|
|
5
|
+
"mappings": ";;AAAA,YAAY,YAAY;AACxB,SAAS,gCAAgC;AACzC,OAAO,aAAa;AACpB,OAAO,aAAa;AAEpB,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAgB5B,MAAM,OAAO;AAAA,EAtBpB,OAsBoB;AAAA;AAAA;AAAA,EAClB,OAAe;AAAA,EACP;AAAA,EAEA;AAAA,EAED,sBAAsB;AAAA,EAErB,yBAAyB;AAAA;AAAA,EAEzB,cAAc;AACpB,SAAK,cAAc,QAAQ,IAAI;AAE/B,UAAM,eAAe,KAAK,gBAAgB;AAE1C,UAAM,eAAuD;AAAA,MAC3D,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP,WAAW;AAAA,MACX,WAAW;AAAA,MACX,OAAO;AAAA,MACP,UAAU;AAAA,MACV,OAAO;AAAA,MACP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,oBAAoB,SAAS,KAAK,qBAAqB;AACzD,aAAO,iBAAiB,QAAQ;AAAA,IAClC;AAAA,EACF;AAAA,EAEO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKS;AACP,SAAK,IAAI,EAAE,OAAO,SAAS,MAAM,QAAQ,CAAC;AAAA,EAC5C;AACF;AAEA,IAAO,iBAAQ,OAAO,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance-monitor.d.ts","sourceRoot":"","sources":["../../src/performance/performance-monitor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"performance-monitor.d.ts","sourceRoot":"","sources":["../../src/performance/performance-monitor.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC5C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC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,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,kBAAkB,EAAE;IAcnF,iBAAiB,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAuB5E,cAAc,IAAI,MAAM,CAAC,WAAW;IAIpC,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAWhD,WAAW,IAAI,MAAM,CAAC,QAAQ;IAI9B,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI;IAI/D,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAWlC,YAAY,IAAI,IAAI;IAIpB,cAAc,IAAI;QACvB,OAAO,EAAE;YACP,YAAY,EAAE,MAAM,CAAC;YACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACjC,UAAU,EAAE,qBAAqB,CAAC;YAClC,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;QACF,OAAO,EAAE,kBAAkB,EAAE,CAAC;QAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC;KACtB;IAcM,uBAAuB,CAAC,MAAM,GAAE,QAAQ,GAAG,UAAuB,GAAG,MAAM;IA+B3E,OAAO,IAAI,IAAI;CAOvB"}
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { PerformanceObserver, performance } from "perf_hooks";
|
|
4
4
|
import { Logger } from "../logger/index.js";
|
|
5
|
+
import { safeSerializeError } from "../error/error-reporter.js";
|
|
5
6
|
class PerformanceMonitor {
|
|
6
7
|
static {
|
|
7
8
|
__name(this, "PerformanceMonitor");
|
|
@@ -143,7 +144,7 @@ class PerformanceMonitor {
|
|
|
143
144
|
performance.clearMarks(endMark);
|
|
144
145
|
} catch (error) {
|
|
145
146
|
Logger.error({
|
|
146
|
-
error: error instanceof Error ? error : new Error(
|
|
147
|
+
error: error instanceof Error ? error : new Error(safeSerializeError(error)),
|
|
147
148
|
message: "Error measuring performance"
|
|
148
149
|
});
|
|
149
150
|
}
|
|
@@ -163,7 +164,10 @@ class PerformanceMonitor {
|
|
|
163
164
|
this.endMeasure(startMark, metadata);
|
|
164
165
|
return result;
|
|
165
166
|
} catch (error) {
|
|
166
|
-
this.endMeasure(startMark, {
|
|
167
|
+
this.endMeasure(startMark, {
|
|
168
|
+
...metadata,
|
|
169
|
+
error: error instanceof Error ? error.message : safeSerializeError(error)
|
|
170
|
+
});
|
|
167
171
|
throw error;
|
|
168
172
|
}
|
|
169
173
|
}
|
|
@@ -177,7 +181,10 @@ class PerformanceMonitor {
|
|
|
177
181
|
this.endMeasure(startMark, metadata);
|
|
178
182
|
return result;
|
|
179
183
|
} catch (error) {
|
|
180
|
-
this.endMeasure(startMark, {
|
|
184
|
+
this.endMeasure(startMark, {
|
|
185
|
+
...metadata,
|
|
186
|
+
error: error instanceof Error ? error.message : safeSerializeError(error)
|
|
187
|
+
});
|
|
181
188
|
throw error;
|
|
182
189
|
}
|
|
183
190
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/performance/performance-monitor.ts"],
|
|
4
|
-
"sourcesContent": ["import { PerformanceObserver, performance } from 'perf_hooks';\nimport { Logger } from '../logger/index.js';\n\nexport interface PerformanceMetrics {\n name: string;\n duration: number;\n timestamp: number;\n type: 'http' | 'database' | 'cache' | 'queue' | 'websocket' | 'custom';\n metadata?: Record<string, any>;\n}\n\nexport interface PerformanceThresholds {\n http: number;\n database: number;\n cache: number;\n queue: number;\n websocket: number;\n custom: number;\n}\n\nexport interface PerformanceMonitorOptions {\n enabled?: boolean;\n maxMetricsHistory?: number;\n thresholds?: Partial<PerformanceThresholds>;\n logSlowOperations?: boolean;\n logAllOperations?: boolean;\n}\n\nexport class PerformanceMonitor {\n private static instance: PerformanceMonitor;\n private observer: PerformanceObserver | undefined;\n private metrics: PerformanceMetrics[] = [];\n // Use Map for aggregation to avoid object prototype risks\n // (No external exposure, but satisfies security linter by avoiding dynamic object keys)\n private thresholds: PerformanceThresholds = {\n http: 1000, // 1 second\n database: 500, // 500ms\n cache: 100, // 100ms\n queue: 2000, // 2 seconds\n websocket: 200, // 200ms\n custom: 1000, // 1 second\n };\n private maxMetricsHistory = 10000;\n private isEnabled = true;\n private logSlowOperations = true;\n private logAllOperations = false;\n\n private constructor(options: PerformanceMonitorOptions = {}) {\n this.isEnabled = options.enabled ?? true;\n this.maxMetricsHistory = options.maxMetricsHistory ?? 10000;\n this.logSlowOperations = options.logSlowOperations ?? true;\n this.logAllOperations = options.logAllOperations ?? false;\n\n if (options.thresholds) {\n this.thresholds = { ...this.thresholds, ...options.thresholds };\n }\n\n if (this.isEnabled) {\n this.initializeObserver();\n }\n }\n\n public static getInstance(options?: PerformanceMonitorOptions): PerformanceMonitor {\n if (!PerformanceMonitor.instance) {\n PerformanceMonitor.instance = new PerformanceMonitor(options);\n }\n return PerformanceMonitor.instance;\n }\n\n public static initialize(options: PerformanceMonitorOptions = {}): PerformanceMonitor {\n PerformanceMonitor.instance = new PerformanceMonitor(options);\n return PerformanceMonitor.instance;\n }\n\n private initializeObserver(): void {\n this.observer = new PerformanceObserver(items => {\n items.getEntries().forEach(entry => {\n if (entry.name.startsWith('pxl-performance:')) {\n this.handlePerformanceEntry(entry);\n }\n });\n });\n\n this.observer.observe({ entryTypes: ['measure'] });\n }\n\n private handlePerformanceEntry(entry: any): void {\n if (!this.isEnabled) return;\n\n const [, type, name] = entry.name.split(':');\n const metricType = type as PerformanceMetrics['type'];\n\n const metric: PerformanceMetrics = {\n name,\n duration: entry.duration,\n timestamp: Date.now(),\n type: metricType,\n metadata: entry.detail,\n };\n\n this.metrics.push(metric);\n\n // Keep only the most recent metrics\n if (this.metrics.length > this.maxMetricsHistory) {\n this.metrics = this.metrics.slice(-this.maxMetricsHistory);\n }\n\n // Check thresholds and log warnings\n const allowedTypes: PerformanceMetrics['type'][] = ['http', 'database', 'cache', 'queue', 'websocket', 'custom'];\n if (!allowedTypes.includes(metricType)) {\n return;\n }\n // Access threshold via explicit switch to avoid dynamic key access warnings\n let threshold: number;\n switch (metricType) {\n case 'http':\n threshold = this.thresholds.http;\n break;\n case 'database':\n threshold = this.thresholds.database;\n break;\n case 'cache':\n threshold = this.thresholds.cache;\n break;\n case 'queue':\n threshold = this.thresholds.queue;\n break;\n case 'websocket':\n threshold = this.thresholds.websocket;\n break;\n case 'custom':\n threshold = this.thresholds.custom;\n break;\n default:\n threshold = 0; // Should not happen due to earlier filtering\n }\n if (this.logSlowOperations && entry.duration > threshold) {\n Logger.warn({\n message: `Performance threshold exceeded`,\n meta: {\n operation: entry.name,\n duration: `${entry.duration.toFixed(2)}ms`,\n threshold: `${threshold}ms`,\n type: metricType,\n },\n });\n }\n\n // Log all operations if enabled\n if (this.logAllOperations) {\n Logger.debug({\n message: `Performance metric`,\n meta: {\n operation: entry.name,\n duration: `${entry.duration.toFixed(2)}ms`,\n type: metricType,\n },\n });\n }\n }\n\n public startMeasure(name: string, type: PerformanceMetrics['type'] = 'custom'): string {\n if (!this.isEnabled) return '';\n\n const measureName = `pxl-performance:${type}:${name}`;\n const startMark = `${measureName}-start`;\n\n performance.mark(startMark);\n return startMark;\n }\n\n public endMeasure(startMark: string, _metadata?: Record<string, any>): void {\n if (!this.isEnabled || !startMark) return;\n\n const endMark = `${startMark.replace('-start', '')}-end`;\n const measureName = startMark.replace('-start', '');\n\n performance.mark(endMark);\n\n try {\n performance.measure(measureName, startMark, endMark);\n\n // Clean up marks\n performance.clearMarks(startMark);\n performance.clearMarks(endMark);\n } catch (error) {\n Logger.error({\n error: error instanceof Error ? error : new Error(String(error)),\n message: 'Error measuring performance',\n });\n }\n }\n\n public async measureAsync<T>({\n name,\n type,\n fn,\n metadata,\n }: {\n name: string;\n type: PerformanceMetrics['type'];\n fn: () => Promise<T>;\n metadata?: Record<string, any>;\n }): Promise<T> {\n if (!this.isEnabled) {\n return fn();\n }\n\n const startMark = this.startMeasure(name, type);\n\n try {\n const result = await fn();\n this.endMeasure(startMark, metadata);\n return result;\n } catch (error) {\n this.endMeasure(startMark, { ...metadata, error: error instanceof Error ? error.message : String(error) });\n throw error;\n }\n }\n\n public measureSync<T>(\n name: string,\n type: PerformanceMetrics['type'],\n fn: () => T,\n metadata?: Record<string, any>,\n ): T {\n if (!this.isEnabled) {\n return fn();\n }\n\n const startMark = this.startMeasure(name, type);\n\n try {\n const result = fn();\n this.endMeasure(startMark, metadata);\n return result;\n } catch (error) {\n this.endMeasure(startMark, { ...metadata, error: error instanceof Error ? error.message : String(error) });\n throw error;\n }\n }\n\n public getMetrics(type?: PerformanceMetrics['type'], limit?: number): PerformanceMetrics[] {\n let filteredMetrics = this.metrics;\n\n if (type) {\n filteredMetrics = filteredMetrics.filter(m => m.type === type);\n }\n\n if (limit) {\n filteredMetrics = filteredMetrics.slice(-limit);\n }\n\n return filteredMetrics;\n }\n\n public getAverageMetrics(type?: PerformanceMetrics['type']): Record<string, number> {\n const metrics = this.getMetrics(type);\n const groups = new Map<string, number[]>();\n for (const metric of metrics) {\n const key = metric.name;\n const arr = groups.get(key) ?? [];\n arr.push(metric.duration);\n if (!groups.has(key)) groups.set(key, arr);\n }\n const averagesMap = new Map<string, number>();\n for (const [key, durations] of groups.entries()) {\n const total = durations.reduce((sum, d) => sum + d, 0);\n averagesMap.set(key, total / durations.length);\n }\n // Convert back to plain object for API compatibility\n return Array.from(averagesMap.entries()).reduce<Record<string, number>>((acc, [k, v]) => {\n if (typeof k === 'string') {\n Object.defineProperty(acc, k, { value: v, enumerable: true, configurable: true, writable: false });\n }\n return acc;\n }, Object.create(null));\n }\n\n public getMemoryUsage(): NodeJS.MemoryUsage {\n return process.memoryUsage();\n }\n\n public getDetailedMemoryUsage(): Record<string, number> {\n const usage = process.memoryUsage();\n return {\n rss: Math.round(usage.rss / 1024 / 1024), // MB\n heapTotal: Math.round(usage.heapTotal / 1024 / 1024), // MB\n heapUsed: Math.round(usage.heapUsed / 1024 / 1024), // MB\n external: Math.round(usage.external / 1024 / 1024), // MB\n arrayBuffers: Math.round(usage.arrayBuffers / 1024 / 1024), // MB\n };\n }\n\n public getCpuUsage(): NodeJS.CpuUsage {\n return process.cpuUsage();\n }\n\n public setThresholds(thresholds: Partial<PerformanceThresholds>): void {\n this.thresholds = { ...this.thresholds, ...thresholds };\n }\n\n public setEnabled(enabled: boolean): void {\n this.isEnabled = enabled;\n\n if (enabled && !this.observer) {\n this.initializeObserver();\n } else if (!enabled && this.observer) {\n this.observer.disconnect();\n this.observer = undefined;\n }\n }\n\n public clearMetrics(): void {\n this.metrics = [];\n }\n\n public generateReport(): {\n summary: {\n totalMetrics: number;\n averages: Record<string, number>;\n thresholds: PerformanceThresholds;\n enabled: boolean;\n };\n metrics: PerformanceMetrics[];\n memory: Record<string, number>;\n cpu: NodeJS.CpuUsage;\n } {\n return {\n summary: {\n totalMetrics: this.metrics.length,\n averages: this.getAverageMetrics(),\n thresholds: this.thresholds,\n enabled: this.isEnabled,\n },\n metrics: this.getMetrics(undefined, 100), // Last 100 metrics\n memory: this.getDetailedMemoryUsage(),\n cpu: this.getCpuUsage(),\n };\n }\n\n public generateFormattedReport(format: 'simple' | 'detailed' = 'detailed'): string {\n const report = this.generateReport();\n\n if (format === 'simple') {\n const memoryUsed = report.memory.heapUsed;\n const cpuPercent = Math.round((report.cpu.user + report.cpu.system) / 1000000); // Convert microseconds to rough percentage\n const avgDurations = Object.values(report.summary.averages);\n const avgMetric =\n avgDurations.length > 0 ? Math.round(avgDurations.reduce((sum, val) => sum + val, 0) / avgDurations.length) : 0;\n\n return `Performance Report (summary: ${report.summary.totalMetrics} ops, avg: ${avgMetric}ms | metrics: ${report.metrics.length} | memory: ${memoryUsed}mb | cpu: ${cpuPercent}%)`;\n }\n const lines = [\n 'Performance Report:',\n `Summary: ${report.summary.totalMetrics} operations tracked, enabled: ${report.summary.enabled}`,\n `Metrics: ${report.metrics.length} recent operations recorded`,\n `Memory: RSS: ${report.memory.rss}mb, Heap: ${report.memory.heapUsed}/${report.memory.heapTotal}mb`,\n `CPU: User: ${Math.round(report.cpu.user / 1000)}ms, System: ${Math.round(report.cpu.system / 1000)}ms`,\n ];\n\n if (Object.keys(report.summary.averages).length > 0) {\n lines.push(\n `Averages: ${Object.entries(report.summary.averages)\n .map(([name, avg]) => `${name}: ${Math.round(avg)}ms`)\n .join(', ')}`,\n );\n }\n\n return lines.join('\\n');\n }\n\n public destroy(): void {\n if (this.observer) {\n this.observer.disconnect();\n this.observer = undefined;\n }\n this.metrics = [];\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA,SAAS,qBAAqB,mBAAmB;AACjD,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["import { PerformanceObserver, performance } from 'perf_hooks';\nimport { Logger } from '../logger/index.js';\nimport { safeSerializeError } from '../error/error-reporter.js';\n\nexport interface PerformanceMetrics {\n name: string;\n duration: number;\n timestamp: number;\n type: 'http' | 'database' | 'cache' | 'queue' | 'websocket' | 'custom';\n metadata?: Record<string, any>;\n}\n\nexport interface PerformanceThresholds {\n http: number;\n database: number;\n cache: number;\n queue: number;\n websocket: number;\n custom: number;\n}\n\nexport interface PerformanceMonitorOptions {\n enabled?: boolean;\n maxMetricsHistory?: number;\n thresholds?: Partial<PerformanceThresholds>;\n logSlowOperations?: boolean;\n logAllOperations?: boolean;\n}\n\nexport class PerformanceMonitor {\n private static instance: PerformanceMonitor;\n private observer: PerformanceObserver | undefined;\n private metrics: PerformanceMetrics[] = [];\n // Use Map for aggregation to avoid object prototype risks\n // (No external exposure, but satisfies security linter by avoiding dynamic object keys)\n private thresholds: PerformanceThresholds = {\n http: 1000, // 1 second\n database: 500, // 500ms\n cache: 100, // 100ms\n queue: 2000, // 2 seconds\n websocket: 200, // 200ms\n custom: 1000, // 1 second\n };\n private maxMetricsHistory = 10000;\n private isEnabled = true;\n private logSlowOperations = true;\n private logAllOperations = false;\n\n private constructor(options: PerformanceMonitorOptions = {}) {\n this.isEnabled = options.enabled ?? true;\n this.maxMetricsHistory = options.maxMetricsHistory ?? 10000;\n this.logSlowOperations = options.logSlowOperations ?? true;\n this.logAllOperations = options.logAllOperations ?? false;\n\n if (options.thresholds) {\n this.thresholds = { ...this.thresholds, ...options.thresholds };\n }\n\n if (this.isEnabled) {\n this.initializeObserver();\n }\n }\n\n public static getInstance(options?: PerformanceMonitorOptions): PerformanceMonitor {\n if (!PerformanceMonitor.instance) {\n PerformanceMonitor.instance = new PerformanceMonitor(options);\n }\n return PerformanceMonitor.instance;\n }\n\n public static initialize(options: PerformanceMonitorOptions = {}): PerformanceMonitor {\n PerformanceMonitor.instance = new PerformanceMonitor(options);\n return PerformanceMonitor.instance;\n }\n\n private initializeObserver(): void {\n this.observer = new PerformanceObserver(items => {\n items.getEntries().forEach(entry => {\n if (entry.name.startsWith('pxl-performance:')) {\n this.handlePerformanceEntry(entry);\n }\n });\n });\n\n this.observer.observe({ entryTypes: ['measure'] });\n }\n\n private handlePerformanceEntry(entry: any): void {\n if (!this.isEnabled) return;\n\n const [, type, name] = entry.name.split(':');\n const metricType = type as PerformanceMetrics['type'];\n\n const metric: PerformanceMetrics = {\n name,\n duration: entry.duration,\n timestamp: Date.now(),\n type: metricType,\n metadata: entry.detail,\n };\n\n this.metrics.push(metric);\n\n // Keep only the most recent metrics\n if (this.metrics.length > this.maxMetricsHistory) {\n this.metrics = this.metrics.slice(-this.maxMetricsHistory);\n }\n\n // Check thresholds and log warnings\n const allowedTypes: PerformanceMetrics['type'][] = ['http', 'database', 'cache', 'queue', 'websocket', 'custom'];\n if (!allowedTypes.includes(metricType)) {\n return;\n }\n // Access threshold via explicit switch to avoid dynamic key access warnings\n let threshold: number;\n switch (metricType) {\n case 'http':\n threshold = this.thresholds.http;\n break;\n case 'database':\n threshold = this.thresholds.database;\n break;\n case 'cache':\n threshold = this.thresholds.cache;\n break;\n case 'queue':\n threshold = this.thresholds.queue;\n break;\n case 'websocket':\n threshold = this.thresholds.websocket;\n break;\n case 'custom':\n threshold = this.thresholds.custom;\n break;\n default:\n threshold = 0; // Should not happen due to earlier filtering\n }\n if (this.logSlowOperations && entry.duration > threshold) {\n Logger.warn({\n message: `Performance threshold exceeded`,\n meta: {\n operation: entry.name,\n duration: `${entry.duration.toFixed(2)}ms`,\n threshold: `${threshold}ms`,\n type: metricType,\n },\n });\n }\n\n // Log all operations if enabled\n if (this.logAllOperations) {\n Logger.debug({\n message: `Performance metric`,\n meta: {\n operation: entry.name,\n duration: `${entry.duration.toFixed(2)}ms`,\n type: metricType,\n },\n });\n }\n }\n\n public startMeasure(name: string, type: PerformanceMetrics['type'] = 'custom'): string {\n if (!this.isEnabled) return '';\n\n const measureName = `pxl-performance:${type}:${name}`;\n const startMark = `${measureName}-start`;\n\n performance.mark(startMark);\n return startMark;\n }\n\n public endMeasure(startMark: string, _metadata?: Record<string, any>): void {\n if (!this.isEnabled || !startMark) return;\n\n const endMark = `${startMark.replace('-start', '')}-end`;\n const measureName = startMark.replace('-start', '');\n\n performance.mark(endMark);\n\n try {\n performance.measure(measureName, startMark, endMark);\n\n // Clean up marks\n performance.clearMarks(startMark);\n performance.clearMarks(endMark);\n } catch (error) {\n Logger.error({\n error: error instanceof Error ? error : new Error(safeSerializeError(error)),\n message: 'Error measuring performance',\n });\n }\n }\n\n public async measureAsync<T>({\n name,\n type,\n fn,\n metadata,\n }: {\n name: string;\n type: PerformanceMetrics['type'];\n fn: () => Promise<T>;\n metadata?: Record<string, any>;\n }): Promise<T> {\n if (!this.isEnabled) {\n return fn();\n }\n\n const startMark = this.startMeasure(name, type);\n\n try {\n const result = await fn();\n this.endMeasure(startMark, metadata);\n return result;\n } catch (error) {\n this.endMeasure(startMark, {\n ...metadata,\n error: error instanceof Error ? error.message : safeSerializeError(error),\n });\n throw error;\n }\n }\n\n public measureSync<T>(\n name: string,\n type: PerformanceMetrics['type'],\n fn: () => T,\n metadata?: Record<string, any>,\n ): T {\n if (!this.isEnabled) {\n return fn();\n }\n\n const startMark = this.startMeasure(name, type);\n\n try {\n const result = fn();\n this.endMeasure(startMark, metadata);\n return result;\n } catch (error) {\n this.endMeasure(startMark, {\n ...metadata,\n error: error instanceof Error ? error.message : safeSerializeError(error),\n });\n throw error;\n }\n }\n\n public getMetrics(type?: PerformanceMetrics['type'], limit?: number): PerformanceMetrics[] {\n let filteredMetrics = this.metrics;\n\n if (type) {\n filteredMetrics = filteredMetrics.filter(m => m.type === type);\n }\n\n if (limit) {\n filteredMetrics = filteredMetrics.slice(-limit);\n }\n\n return filteredMetrics;\n }\n\n public getAverageMetrics(type?: PerformanceMetrics['type']): Record<string, number> {\n const metrics = this.getMetrics(type);\n const groups = new Map<string, number[]>();\n for (const metric of metrics) {\n const key = metric.name;\n const arr = groups.get(key) ?? [];\n arr.push(metric.duration);\n if (!groups.has(key)) groups.set(key, arr);\n }\n const averagesMap = new Map<string, number>();\n for (const [key, durations] of groups.entries()) {\n const total = durations.reduce((sum, d) => sum + d, 0);\n averagesMap.set(key, total / durations.length);\n }\n // Convert back to plain object for API compatibility\n return Array.from(averagesMap.entries()).reduce<Record<string, number>>((acc, [k, v]) => {\n if (typeof k === 'string') {\n Object.defineProperty(acc, k, { value: v, enumerable: true, configurable: true, writable: false });\n }\n return acc;\n }, Object.create(null));\n }\n\n public getMemoryUsage(): NodeJS.MemoryUsage {\n return process.memoryUsage();\n }\n\n public getDetailedMemoryUsage(): Record<string, number> {\n const usage = process.memoryUsage();\n return {\n rss: Math.round(usage.rss / 1024 / 1024), // MB\n heapTotal: Math.round(usage.heapTotal / 1024 / 1024), // MB\n heapUsed: Math.round(usage.heapUsed / 1024 / 1024), // MB\n external: Math.round(usage.external / 1024 / 1024), // MB\n arrayBuffers: Math.round(usage.arrayBuffers / 1024 / 1024), // MB\n };\n }\n\n public getCpuUsage(): NodeJS.CpuUsage {\n return process.cpuUsage();\n }\n\n public setThresholds(thresholds: Partial<PerformanceThresholds>): void {\n this.thresholds = { ...this.thresholds, ...thresholds };\n }\n\n public setEnabled(enabled: boolean): void {\n this.isEnabled = enabled;\n\n if (enabled && !this.observer) {\n this.initializeObserver();\n } else if (!enabled && this.observer) {\n this.observer.disconnect();\n this.observer = undefined;\n }\n }\n\n public clearMetrics(): void {\n this.metrics = [];\n }\n\n public generateReport(): {\n summary: {\n totalMetrics: number;\n averages: Record<string, number>;\n thresholds: PerformanceThresholds;\n enabled: boolean;\n };\n metrics: PerformanceMetrics[];\n memory: Record<string, number>;\n cpu: NodeJS.CpuUsage;\n } {\n return {\n summary: {\n totalMetrics: this.metrics.length,\n averages: this.getAverageMetrics(),\n thresholds: this.thresholds,\n enabled: this.isEnabled,\n },\n metrics: this.getMetrics(undefined, 100), // Last 100 metrics\n memory: this.getDetailedMemoryUsage(),\n cpu: this.getCpuUsage(),\n };\n }\n\n public generateFormattedReport(format: 'simple' | 'detailed' = 'detailed'): string {\n const report = this.generateReport();\n\n if (format === 'simple') {\n const memoryUsed = report.memory.heapUsed;\n const cpuPercent = Math.round((report.cpu.user + report.cpu.system) / 1000000); // Convert microseconds to rough percentage\n const avgDurations = Object.values(report.summary.averages);\n const avgMetric =\n avgDurations.length > 0 ? Math.round(avgDurations.reduce((sum, val) => sum + val, 0) / avgDurations.length) : 0;\n\n return `Performance Report (summary: ${report.summary.totalMetrics} ops, avg: ${avgMetric}ms | metrics: ${report.metrics.length} | memory: ${memoryUsed}mb | cpu: ${cpuPercent}%)`;\n }\n const lines = [\n 'Performance Report:',\n `Summary: ${report.summary.totalMetrics} operations tracked, enabled: ${report.summary.enabled}`,\n `Metrics: ${report.metrics.length} recent operations recorded`,\n `Memory: RSS: ${report.memory.rss}mb, Heap: ${report.memory.heapUsed}/${report.memory.heapTotal}mb`,\n `CPU: User: ${Math.round(report.cpu.user / 1000)}ms, System: ${Math.round(report.cpu.system / 1000)}ms`,\n ];\n\n if (Object.keys(report.summary.averages).length > 0) {\n lines.push(\n `Averages: ${Object.entries(report.summary.averages)\n .map(([name, avg]) => `${name}: ${Math.round(avg)}ms`)\n .join(', ')}`,\n );\n }\n\n return lines.join('\\n');\n }\n\n public destroy(): void {\n if (this.observer) {\n this.observer.disconnect();\n this.observer = undefined;\n }\n this.metrics = [];\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,qBAAqB,mBAAmB;AACjD,SAAS,cAAc;AACvB,SAAS,0BAA0B;AA2B5B,MAAM,mBAAmB;AAAA,EA7BhC,OA6BgC;AAAA;AAAA;AAAA,EAC9B,OAAe;AAAA,EACP;AAAA,EACA,UAAgC,CAAC;AAAA;AAAA;AAAA,EAGjC,aAAoC;AAAA,IAC1C,MAAM;AAAA;AAAA,IACN,UAAU;AAAA;AAAA,IACV,OAAO;AAAA;AAAA,IACP,OAAO;AAAA;AAAA,IACP,WAAW;AAAA;AAAA,IACX,QAAQ;AAAA;AAAA,EACV;AAAA,EACQ,oBAAoB;AAAA,EACpB,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EAEnB,YAAY,UAAqC,CAAC,GAAG;AAC3D,SAAK,YAAY,QAAQ,WAAW;AACpC,SAAK,oBAAoB,QAAQ,qBAAqB;AACtD,SAAK,oBAAoB,QAAQ,qBAAqB;AACtD,SAAK,mBAAmB,QAAQ,oBAAoB;AAEpD,QAAI,QAAQ,YAAY;AACtB,WAAK,aAAa,EAAE,GAAG,KAAK,YAAY,GAAG,QAAQ,WAAW;AAAA,IAChE;AAEA,QAAI,KAAK,WAAW;AAClB,WAAK,mBAAmB;AAAA,IAC1B;AAAA,EACF;AAAA,EAEA,OAAc,YAAY,SAAyD;AACjF,QAAI,CAAC,mBAAmB,UAAU;AAChC,yBAAmB,WAAW,IAAI,mBAAmB,OAAO;AAAA,IAC9D;AACA,WAAO,mBAAmB;AAA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;AAAA,MACjC,gBAAgB,OAAO,OAAO,GAAG,aAAa,OAAO,OAAO,QAAQ,IAAI,OAAO,OAAO,SAAS;AAAA,MAC/F,cAAc,KAAK,MAAM,OAAO,IAAI,OAAO,GAAI,CAAC,eAAe,KAAK,MAAM,OAAO,IAAI,SAAS,GAAI,CAAC;AAAA,IACrG;AAEA,QAAI,OAAO,KAAK,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAAG;AACnD,YAAM;AAAA,QACJ,aAAa,OAAO,QAAQ,OAAO,QAAQ,QAAQ,EAChD,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,KAAK,KAAK,MAAM,GAAG,CAAC,IAAI,EACpD,KAAK,IAAI,CAAC;AAAA,MACf;AAAA,IACF;AAEA,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AAAA,EAEO,UAAgB;AACrB,QAAI,KAAK,UAAU;AACjB,WAAK,SAAS,WAAW;AACzB,WAAK,WAAW;AAAA,IAClB;AACA,SAAK,UAAU,CAAC;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/queue/processor/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAEzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../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E,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;wBAI7C,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;yBAI5C,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;MAG9D;CACH"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { Logger } from "../../logger/index.js";
|
|
4
|
+
import { safeSerializeError } from "../../error/error-reporter.js";
|
|
4
5
|
class BaseProcessor {
|
|
5
6
|
constructor(queueManager, applicationConfig, redisInstance, databaseInstance, eventManager) {
|
|
6
7
|
this.queueManager = queueManager;
|
|
@@ -21,7 +22,7 @@ class BaseProcessor {
|
|
|
21
22
|
if (message) {
|
|
22
23
|
const errorMeta = {
|
|
23
24
|
...meta ?? {},
|
|
24
|
-
error: error instanceof Error ? error.message :
|
|
25
|
+
error: error instanceof Error ? error.message : safeSerializeError(error),
|
|
25
26
|
stack: error instanceof Error ? error.stack : void 0
|
|
26
27
|
};
|
|
27
28
|
this.logger.custom({ level: "queueJob", message, meta: errorMeta });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/queue/processor/base.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Job } from 'bullmq';\nimport type { QueueManager } from '../../queue/index.js';\nimport type { DatabaseInstance } from '../../database/index.js';\nimport type { ApplicationConfig } from '../../application/base-application.interface.js';\nimport { Logger } from '../../logger/index.js';\nimport type { RedisInstance } from '../../redis/index.js';\nimport type EventManager from '../../event/manager.js';\nimport type { QueueJobData } from '../job.interface.js';\n\nexport default abstract class BaseProcessor<\n TQueueManager extends QueueManager = QueueManager,\n TJobData extends QueueJobData = QueueJobData,\n TResult = unknown,\n> {\n private logger: typeof Logger = Logger;\n\n constructor(\n protected queueManager: TQueueManager,\n protected applicationConfig: ApplicationConfig,\n protected redisInstance: RedisInstance,\n protected databaseInstance: DatabaseInstance | null,\n protected eventManager?: EventManager,\n ) {}\n\n public abstract process({ job }: { job: Job<TJobData, TResult> }): Promise<TResult>;\n\n /**\n * Enhanced logger with structured methods\n */\n public log = {\n error: (error: Error | unknown, message?: string, meta?: Record<string, unknown>): void => {\n if (message) {\n const errorMeta = {\n ...(meta ?? {}),\n error: error instanceof Error ? error.message :
|
|
5
|
-
"mappings": ";;AAIA,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["import type { Job } from 'bullmq';\nimport type { QueueManager } from '../../queue/index.js';\nimport type { DatabaseInstance } from '../../database/index.js';\nimport type { ApplicationConfig } from '../../application/base-application.interface.js';\nimport { Logger } from '../../logger/index.js';\nimport type { RedisInstance } from '../../redis/index.js';\nimport type EventManager from '../../event/manager.js';\nimport type { QueueJobData } from '../job.interface.js';\nimport { safeSerializeError } from '../../error/error-reporter.js';\n\nexport default abstract class BaseProcessor<\n TQueueManager extends QueueManager = QueueManager,\n TJobData extends QueueJobData = QueueJobData,\n TResult = unknown,\n> {\n private logger: typeof Logger = Logger;\n\n constructor(\n protected queueManager: TQueueManager,\n protected applicationConfig: ApplicationConfig,\n protected redisInstance: RedisInstance,\n protected databaseInstance: DatabaseInstance | null,\n protected eventManager?: EventManager,\n ) {}\n\n public abstract process({ job }: { job: Job<TJobData, TResult> }): Promise<TResult>;\n\n /**\n * Enhanced logger with structured methods\n */\n public log = {\n error: (error: Error | unknown, message?: string, meta?: Record<string, unknown>): void => {\n if (message) {\n const errorMeta = {\n ...(meta ?? {}),\n error: error instanceof Error ? error.message : safeSerializeError(error),\n stack: error instanceof Error ? error.stack : undefined,\n };\n this.logger.custom({ level: 'queueJob', message, meta: errorMeta });\n } else {\n this.logger.custom({ level: 'queueJob', message: error });\n }\n },\n\n info: (message: string, meta?: Record<string, unknown>): void => {\n this.logger.custom({ level: 'queueJob', message, meta });\n },\n\n warn: (message: string, meta?: Record<string, unknown>): void => {\n this.logger.custom({ level: 'queueJob', message, meta });\n },\n\n debug: (message: string, meta?: Record<string, unknown>): void => {\n this.logger.custom({ level: 'queueJob', message, meta });\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;AAIA,SAAS,cAAc;AAIvB,SAAS,0BAA0B;AAEnC,MAAO,cAIL;AAAA,EAGA,YACY,cACA,mBACA,eACA,kBACA,cACV;AALU;AACA;AACA;AACA;AACA;AAAA,EACT;AAAA,EAvBL,OAcE;AAAA;AAAA;AAAA,EACQ,SAAwB;AAAA;AAAA;AAAA;AAAA,EAezB,MAAM;AAAA,IACX,OAAO,wBAAC,OAAwB,SAAkB,SAAyC;AACzF,UAAI,SAAS;AACX,cAAM,YAAY;AAAA,UAChB,GAAI,QAAQ,CAAC;AAAA,UACb,OAAO,iBAAiB,QAAQ,MAAM,UAAU,mBAAmB,KAAK;AAAA,UACxE,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,QAChD;AACA,aAAK,OAAO,OAAO,EAAE,OAAO,YAAY,SAAS,MAAM,UAAU,CAAC;AAAA,MACpE,OAAO;AACL,aAAK,OAAO,OAAO,EAAE,OAAO,YAAY,SAAS,MAAM,CAAC;AAAA,MAC1D;AAAA,IACF,GAXO;AAAA,IAaP,MAAM,wBAAC,SAAiB,SAAyC;AAC/D,WAAK,OAAO,OAAO,EAAE,OAAO,YAAY,SAAS,KAAK,CAAC;AAAA,IACzD,GAFM;AAAA,IAIN,MAAM,wBAAC,SAAiB,SAAyC;AAC/D,WAAK,OAAO,OAAO,EAAE,OAAO,YAAY,SAAS,KAAK,CAAC;AAAA,IACzD,GAFM;AAAA,IAIN,OAAO,wBAAC,SAAiB,SAAyC;AAChE,WAAK,OAAO,OAAO,EAAE,OAAO,YAAY,SAAS,KAAK,CAAC;AAAA,IACzD,GAFO;AAAA,EAGT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/redis/manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,aAAa,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/redis/manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,aAAa,MAAM,eAAe,CAAC;AAwJ1C,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,OAAO,CAAC,MAAM,CAAyB;IAEvC,OAAO,CAAC,OAAO,CAAsB;IAE9B,SAAS,EAAE,aAAa,EAAE,CAAM;gBAE3B,MAAM,EAAE,mBAAmB;IAI1B,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAkGjC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAiDxC;;OAEG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAGlE"}
|
package/dist/redis/manager.js
CHANGED
|
@@ -5,6 +5,7 @@ import { EventEmitter } from "node:events";
|
|
|
5
5
|
import RedisInstance from "./instance.js";
|
|
6
6
|
import { Logger } from "../logger/index.js";
|
|
7
7
|
import { CachePerformanceWrapper } from "../performance/index.js";
|
|
8
|
+
import { safeSerializeError } from "../error/error-reporter.js";
|
|
8
9
|
const truthyPattern = /^(1|true|yes|on)$/i;
|
|
9
10
|
const scheduleMicrotask = typeof globalThis.queueMicrotask === "function" ? globalThis.queueMicrotask.bind(globalThis) : (callback) => {
|
|
10
11
|
void Promise.resolve().then(callback);
|
|
@@ -190,7 +191,7 @@ class RedisManager {
|
|
|
190
191
|
const duration = performance.now() - startTime;
|
|
191
192
|
await Promise.allSettled([client.quit(), publisherClient.quit(), subscriberClient.quit()]);
|
|
192
193
|
this.logger.error({
|
|
193
|
-
error: error instanceof Error ? error : new Error(
|
|
194
|
+
error: error instanceof Error ? error : new Error(safeSerializeError(error)),
|
|
194
195
|
message: "Redis connection failed",
|
|
195
196
|
meta: {
|
|
196
197
|
Host: this.options.host,
|
|
@@ -231,7 +232,7 @@ class RedisManager {
|
|
|
231
232
|
} catch (error) {
|
|
232
233
|
const duration = performance.now() - startTime;
|
|
233
234
|
this.logger.error({
|
|
234
|
-
error: error instanceof Error ? error : new Error(
|
|
235
|
+
error: error instanceof Error ? error : new Error(safeSerializeError(error)),
|
|
235
236
|
message: "Redis disconnection failed",
|
|
236
237
|
meta: {
|
|
237
238
|
Host: this.options.host,
|