@org-quicko/core 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/browser/beans/BaseObject.js +74 -0
  2. package/dist/browser/beans/BaseObject.js.map +1 -0
  3. package/dist/browser/beans/index.js +2 -0
  4. package/dist/{esm → browser/beans}/index.js.map +1 -1
  5. package/dist/browser/build/browser/index.js +14 -0
  6. package/dist/browser/build/browser/index.js.map +1 -0
  7. package/dist/browser/exceptions/BadRequestException.js +14 -0
  8. package/dist/browser/exceptions/BadRequestException.js.map +1 -0
  9. package/dist/browser/exceptions/BaseException.js +35 -0
  10. package/dist/browser/exceptions/BaseException.js.map +1 -0
  11. package/dist/browser/exceptions/ClientException.js +14 -0
  12. package/dist/browser/exceptions/ClientException.js.map +1 -0
  13. package/dist/browser/exceptions/ConverterException.js +13 -0
  14. package/dist/browser/exceptions/ConverterException.js.map +1 -0
  15. package/dist/browser/exceptions/ForbiddenAccessException.js +14 -0
  16. package/dist/browser/exceptions/ForbiddenAccessException.js.map +1 -0
  17. package/dist/browser/exceptions/HTTPException.js +14 -0
  18. package/dist/browser/exceptions/HTTPException.js.map +1 -0
  19. package/dist/browser/exceptions/IllegalArgumentException.js +13 -0
  20. package/dist/browser/exceptions/IllegalArgumentException.js.map +1 -0
  21. package/dist/browser/exceptions/UnauthorizedException.js +14 -0
  22. package/dist/browser/exceptions/UnauthorizedException.js.map +1 -0
  23. package/dist/browser/exceptions/index.js +9 -0
  24. package/dist/browser/exceptions/index.js.map +1 -0
  25. package/dist/browser/types/JSONObject.js +136 -0
  26. package/dist/browser/types/JSONObject.js.map +1 -0
  27. package/dist/browser/types/LoggingLevel.js +12 -0
  28. package/dist/browser/types/LoggingLevel.js.map +1 -0
  29. package/dist/browser/types/SortOrder.js +12 -0
  30. package/dist/browser/types/SortOrder.js.map +1 -0
  31. package/dist/browser/types/index.js +4 -0
  32. package/dist/browser/types/index.js.map +1 -0
  33. package/dist/browser/utils/date/DateUtil.js +157 -0
  34. package/dist/browser/utils/date/DateUtil.js.map +1 -0
  35. package/dist/browser/utils/date/index.js +2 -0
  36. package/dist/browser/utils/date/index.js.map +1 -0
  37. package/dist/browser/utils/index.js +2 -0
  38. package/dist/browser/utils/index.js.map +1 -0
  39. package/dist/cjs/beans/index.cjs +8 -0
  40. package/dist/cjs/beans/index.cjs.map +1 -0
  41. package/dist/cjs/build/node/index.cjs +42 -0
  42. package/dist/cjs/{index.cjs.map → build/node/index.cjs.map} +1 -1
  43. package/dist/cjs/exceptions/BadRequestException.cjs.map +1 -1
  44. package/dist/cjs/exceptions/ClientException.cjs.map +1 -1
  45. package/dist/cjs/exceptions/ConverterException.cjs.map +1 -1
  46. package/dist/cjs/exceptions/ForbiddenAccessException.cjs.map +1 -1
  47. package/dist/cjs/exceptions/HTTPException.cjs.map +1 -1
  48. package/dist/cjs/exceptions/IllegalArgumentException.cjs.map +1 -1
  49. package/dist/cjs/exceptions/UnauthorizedException.cjs.map +1 -1
  50. package/dist/cjs/exceptions/index.cjs +22 -0
  51. package/dist/cjs/exceptions/index.cjs.map +1 -0
  52. package/dist/cjs/logger/LoggerFactory.cjs +44 -0
  53. package/dist/cjs/logger/LoggerFactory.cjs.map +1 -0
  54. package/dist/cjs/logger/index.cjs +9 -0
  55. package/dist/cjs/logger/index.cjs.map +1 -0
  56. package/dist/cjs/types/JSONObject.cjs +6 -6
  57. package/dist/cjs/types/JSONObject.cjs.map +1 -1
  58. package/dist/cjs/types/index.cjs +19 -0
  59. package/dist/cjs/types/index.cjs.map +1 -0
  60. package/dist/cjs/utils/date/DateUtil.cjs.map +1 -1
  61. package/dist/cjs/utils/date/index.cjs +8 -0
  62. package/dist/cjs/utils/date/index.cjs.map +1 -0
  63. package/dist/cjs/utils/index.cjs +8 -0
  64. package/dist/cjs/utils/index.cjs.map +1 -0
  65. package/dist/esm/beans/index.js +2 -0
  66. package/dist/esm/beans/index.js.map +1 -0
  67. package/dist/esm/build/node/index.js +15 -0
  68. package/dist/esm/build/node/index.js.map +1 -0
  69. package/dist/esm/exceptions/BadRequestException.js.map +1 -1
  70. package/dist/esm/exceptions/ClientException.js.map +1 -1
  71. package/dist/esm/exceptions/ConverterException.js.map +1 -1
  72. package/dist/esm/exceptions/ForbiddenAccessException.js.map +1 -1
  73. package/dist/esm/exceptions/HTTPException.js.map +1 -1
  74. package/dist/esm/exceptions/IllegalArgumentException.js.map +1 -1
  75. package/dist/esm/exceptions/UnauthorizedException.js.map +1 -1
  76. package/dist/esm/exceptions/index.js +9 -0
  77. package/dist/esm/exceptions/index.js.map +1 -0
  78. package/dist/esm/logger/LoggerFactory.js +41 -0
  79. package/dist/esm/logger/LoggerFactory.js.map +1 -0
  80. package/dist/esm/logger/index.js +2 -0
  81. package/dist/esm/logger/index.js.map +1 -0
  82. package/dist/esm/types/JSONObject.js +6 -6
  83. package/dist/esm/types/JSONObject.js.map +1 -1
  84. package/dist/esm/types/index.js +4 -0
  85. package/dist/esm/types/index.js.map +1 -0
  86. package/dist/esm/utils/date/DateUtil.js.map +1 -1
  87. package/dist/esm/utils/date/index.js +2 -0
  88. package/dist/esm/utils/date/index.js.map +1 -0
  89. package/dist/esm/utils/index.js +2 -0
  90. package/dist/esm/utils/index.js.map +1 -0
  91. package/dist/types/index.d.ts +14 -18
  92. package/dist/types/src/beans/index.d.ts +1 -0
  93. package/dist/types/src/exceptions/index.d.ts +8 -0
  94. package/dist/types/src/logger/LoggerFactory.d.ts +19 -0
  95. package/dist/types/src/logger/index.d.ts +1 -0
  96. package/dist/types/src/types/index.d.ts +3 -0
  97. package/dist/types/src/utils/date/index.d.ts +1 -0
  98. package/dist/types/src/utils/index.d.ts +1 -0
  99. package/package.json +33 -63
  100. package/dist/cjs/exceptions/NullPointerException.cjs +0 -15
  101. package/dist/cjs/exceptions/NullPointerException.cjs.map +0 -1
  102. package/dist/cjs/index.cjs +0 -48
  103. package/dist/cjs/logger/MDC.cjs +0 -77
  104. package/dist/cjs/logger/MDC.cjs.map +0 -1
  105. package/dist/cjs/logger/factory/ConsoleLoggerProvider.cjs +0 -43
  106. package/dist/cjs/logger/factory/ConsoleLoggerProvider.cjs.map +0 -1
  107. package/dist/cjs/logger/factory/LoggerFactory.cjs +0 -31
  108. package/dist/cjs/logger/factory/LoggerFactory.cjs.map +0 -1
  109. package/dist/esm/exceptions/NullPointerException.js +0 -13
  110. package/dist/esm/exceptions/NullPointerException.js.map +0 -1
  111. package/dist/esm/index.js +0 -18
  112. package/dist/esm/logger/MDC.js +0 -75
  113. package/dist/esm/logger/MDC.js.map +0 -1
  114. package/dist/esm/logger/factory/ConsoleLoggerProvider.js +0 -41
  115. package/dist/esm/logger/factory/ConsoleLoggerProvider.js.map +0 -1
  116. package/dist/esm/logger/factory/LoggerFactory.js +0 -28
  117. package/dist/esm/logger/factory/LoggerFactory.js.map +0 -1
  118. package/dist/types/exceptions/NullPointerException.d.ts +0 -10
  119. package/dist/types/logger/MDC.d.ts +0 -53
  120. package/dist/types/logger/factory/ConsoleLoggerProvider.d.ts +0 -20
  121. package/dist/types/logger/factory/LoggerFactory.d.ts +0 -25
  122. package/dist/types/logger/factory/LoggerProvider.d.ts +0 -16
  123. /package/dist/types/{beans → src/beans}/BaseObject.d.ts +0 -0
  124. /package/dist/types/{exceptions → src/exceptions}/BadRequestException.d.ts +0 -0
  125. /package/dist/types/{exceptions → src/exceptions}/BaseException.d.ts +0 -0
  126. /package/dist/types/{exceptions → src/exceptions}/ClientException.d.ts +0 -0
  127. /package/dist/types/{exceptions → src/exceptions}/ConverterException.d.ts +0 -0
  128. /package/dist/types/{exceptions → src/exceptions}/ForbiddenAccessException.d.ts +0 -0
  129. /package/dist/types/{exceptions → src/exceptions}/HTTPException.d.ts +0 -0
  130. /package/dist/types/{exceptions → src/exceptions}/IllegalArgumentException.d.ts +0 -0
  131. /package/dist/types/{exceptions → src/exceptions}/UnauthorizedException.d.ts +0 -0
  132. /package/dist/types/{types → src/types}/JSONObject.d.ts +0 -0
  133. /package/dist/types/{types → src/types}/LoggingLevel.d.ts +0 -0
  134. /package/dist/types/{types → src/types}/SortOrder.d.ts +0 -0
  135. /package/dist/types/{utils → src/utils}/date/DateUtil.d.ts +0 -0
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@org-quicko/core",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "A library in typescript for common entities and utilities across Quicko",
5
5
  "author": "Quicko",
6
- "main": "dist/cjs/index.cjs",
7
- "module": "dist/esm/index.js",
6
+ "main": "dist/cjs/build/node/index.cjs",
7
+ "module": "dist/esm/build/node/index.js",
8
+ "browser": "dist/browser/build/browser/index.js",
8
9
  "types": "dist/types/index.d.ts",
9
10
  "type": "module",
10
11
  "scripts": {
@@ -22,86 +23,57 @@
22
23
  ".": {
23
24
  "types": "./dist/types/index.d.ts",
24
25
  "node": {
25
- "import": "./dist/esm/index.js",
26
- "require": "./dist/cjs/index.cjs"
26
+ "import": "./dist/esm/build/node/index.js",
27
+ "require": "./dist/cjs/build/node/index.cjs"
27
28
  },
28
- "browser": {
29
- "import": "./dist/esm/index.js",
30
- "require": "./dist/cjs/index.cjs"
31
- },
32
- "default": "./dist/esm/index.js"
29
+ "default": "./dist/browser/build/browser/index.js"
33
30
  },
34
31
  "./beans": {
35
32
  "types": "./dist/types/src/beans/index.d.ts",
36
33
  "node": {
37
- "import": "./dist/esm/src/beans/index.js",
38
- "require": "./dist/cjs/src/beans/index.cjs"
39
- },
40
- "browser": {
41
- "import": "./dist/esm/src/beans/index.js",
42
- "require": "./dist/cjs/src/beans/index.cjs"
34
+ "import": "./dist/esm/beans/index.js",
35
+ "require": "./dist/cjs/beans/index.cjs"
43
36
  },
44
- "default": "./dist/esm/src/beans/index.js"
37
+ "default": "./dist/browser/beans/index.js"
45
38
  },
46
39
  "./types": {
47
40
  "types": "./dist/types/src/types/index.d.ts",
48
41
  "node": {
49
- "import": "./dist/esm/src/types/index.js",
50
- "require": "./dist/cjs/src/types/index.cjs"
51
- },
52
- "browser": {
53
- "import": "./dist/esm/src/types/index.js",
54
- "require": "./dist/cjs/src/types/index.cjs"
42
+ "import": "./dist/esm/types/index.js",
43
+ "require": "./dist/cjs/types/index.cjs"
55
44
  },
56
- "default": "./dist/esm/src/types/index.js"
45
+ "default": "./dist/browser/types/index.js"
57
46
  },
58
47
  "./utils": {
59
48
  "types": "./dist/types/src/utils/index.d.ts",
60
49
  "node": {
61
- "import": "./dist/esm/src/utils/index.js",
62
- "require": "./dist/cjs/src/utils/index.cjs"
50
+ "import": "./dist/esm/utils/index.js",
51
+ "require": "./dist/cjs/utils/index.cjs"
63
52
  },
64
- "browser": {
65
- "import": "./dist/esm/src/utils/index.js",
66
- "require": "./dist/cjs/src/utils/index.cjs"
67
- },
68
- "default": "./dist/esm/src/utils/index.js"
53
+ "default": "./dist/browser/utils/index.js"
69
54
  },
70
55
  "./utils/date": {
71
56
  "types": "./dist/types/src/utils/date/index.d.ts",
72
57
  "node": {
73
- "import": "./dist/esm/src/utils/date/index.js",
74
- "require": "./dist/cjs/src/utils/date/index.cjs"
75
- },
76
- "browser": {
77
- "import": "./dist/esm/src/utils/date/index.js",
78
- "require": "./dist/cjs/src/utils/date/index.cjs"
58
+ "import": "./dist/esm/utils/date/index.js",
59
+ "require": "./dist/cjs/utils/date/index.cjs"
79
60
  },
80
- "default": "./dist/esm/src/utils/date/index.js"
61
+ "default": "./dist/browser/utils/date/index.js"
81
62
  },
82
63
  "./logger": {
83
64
  "types": "./dist/types/src/logger/index.d.ts",
84
65
  "node": {
85
- "import": "./dist/esm/src/logger/index.js",
86
- "require": "./dist/cjs/src/logger/index.cjs"
87
- },
88
- "browser": {
89
- "import": "./dist/esm/src/logger/index.js",
90
- "require": "./dist/cjs/src/logger/index.cjs"
91
- },
92
- "default": "./dist/esm/src/logger/index.js"
66
+ "import": "./dist/esm/logger/index.js",
67
+ "require": "./dist/cjs/logger/index.cjs"
68
+ }
93
69
  },
94
70
  "./exceptions": {
95
71
  "types": "./dist/types/src/exceptions/index.d.ts",
96
72
  "node": {
97
- "import": "./dist/esm/src/exceptions/index.js",
98
- "require": "./dist/cjs/src/exceptions/index.cjs"
99
- },
100
- "browser": {
101
- "import": "./dist/esm/src/exceptions/index.js",
102
- "require": "./dist/cjs/src/exceptions/index.cjs"
73
+ "import": "./dist/esm/exceptions/index.js",
74
+ "require": "./dist/cjs/exceptions/index.cjs"
103
75
  },
104
- "default": "./dist/esm/src/exceptions/index.js"
76
+ "default": "./dist/browser/exceptions/index.js"
105
77
  },
106
78
  "./package.json": "./package.json"
107
79
  },
@@ -145,22 +117,20 @@
145
117
  "winston": "^3.17.0"
146
118
  },
147
119
  "devDependencies": {
148
- "@types/node": "^22.7.0",
149
- "@typescript-eslint/eslint-plugin": "^8.17.0",
150
- "@typescript-eslint/parser": "^8.17.0",
151
120
  "@rollup/plugin-commonjs": "^28.0.3",
152
121
  "@rollup/plugin-node-resolve": "^16.0.1",
153
- "@rollup/plugin-terser": "^0.4.4",
154
122
  "@rollup/plugin-typescript": "^12.1.2",
123
+ "@types/node": "^22.7.0",
124
+ "@typescript-eslint/eslint-plugin": "^8.33.1",
125
+ "@typescript-eslint/parser": "^8.33.1",
155
126
  "esbuild-plugin-eslint": "^0.3.7",
156
- "rollup-plugin-bundle-size": "^1.0.3",
157
- "rollup-plugin-dts": "^6.2.1",
158
- "eslint": "^8.2.0",
159
- "eslint-config-airbnb": "^19.0.4",
160
- "eslint-config-prettier": "^9.1.0",
127
+ "eslint": "^9.28.0",
128
+ "eslint-config-prettier": "^10.1.5",
161
129
  "eslint-import-resolver-typescript": "^3.7.0",
130
+ "glob": "^11.0.2",
162
131
  "rollup": "^4.40.2",
132
+ "rollup-plugin-dts": "^6.2.1",
163
133
  "ts-node": "^10.9.2",
164
134
  "typescript": "^5.6.2"
165
135
  }
166
- }
136
+ }
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var BaseException = require('./BaseException.cjs');
4
-
5
- /**
6
- * Exception thrown when an operation is attempted on a `null` or `undefined` value.
7
- */
8
- class NullPointerException extends BaseException.BaseException {
9
- constructor(message, cause) {
10
- super(message, cause, 500);
11
- }
12
- }
13
-
14
- exports.NullPointerException = NullPointerException;
15
- //# sourceMappingURL=NullPointerException.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NullPointerException.cjs","sources":["../../../src/exceptions/NullPointerException.ts"],"sourcesContent":["import { BaseException } from \"./BaseException.js\";\r\n\r\n/**\r\n * Exception thrown when an operation is attempted on a `null` or `undefined` value.\r\n */\r\nexport class NullPointerException extends BaseException {\r\n\r\n constructor(message: string, cause?: unknown) {\r\n super(message, cause, 500);\r\n }\r\n}\r\n\r\n"],"names":["BaseException"],"mappings":";;;;AAEA;;AAEG;AACG,MAAO,oBAAqB,SAAQA,2BAAa,CAAA;IAEnD,WAAY,CAAA,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;;AAEjC;;;;"}
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- var BadRequestException = require('./exceptions/BadRequestException.cjs');
4
- var BaseException = require('./exceptions/BaseException.cjs');
5
- var ClientException = require('./exceptions/ClientException.cjs');
6
- var ForbiddenAccessException = require('./exceptions/ForbiddenAccessException.cjs');
7
- var HTTPException = require('./exceptions/HTTPException.cjs');
8
- var IllegalArgumentException = require('./exceptions/IllegalArgumentException.cjs');
9
- var UnauthorizedException = require('./exceptions/UnauthorizedException.cjs');
10
- var NullPointerException = require('./exceptions/NullPointerException.cjs');
11
- var ConverterException = require('./exceptions/ConverterException.cjs');
12
- var ConsoleLoggerProvider = require('./logger/factory/ConsoleLoggerProvider.cjs');
13
- var LoggerFactory = require('./logger/factory/LoggerFactory.cjs');
14
- var MDC = require('./logger/MDC.cjs');
15
- var JSONObject = require('./types/JSONObject.cjs');
16
- var LoggingLevel = require('./types/LoggingLevel.cjs');
17
- var SortOrder = require('./types/SortOrder.cjs');
18
- var BaseObject = require('./beans/BaseObject.cjs');
19
- var DateUtil = require('./utils/date/DateUtil.cjs');
20
-
21
-
22
-
23
- exports.BadRequestException = BadRequestException.BadRequestException;
24
- exports.BaseException = BaseException.BaseException;
25
- exports.ClientException = ClientException.ClientException;
26
- exports.ForbiddenAccessException = ForbiddenAccessException.ForbiddenAccessException;
27
- exports.HTTPException = HTTPException.HTTPException;
28
- exports.IllegalArgumentException = IllegalArgumentException.IllegalArgumentException;
29
- exports.UnauthorizedException = UnauthorizedException.UnauthorizedException;
30
- exports.NullPointerException = NullPointerException.NullPointerException;
31
- exports.ConverterException = ConverterException.ConverterException;
32
- exports.ConsoleLoggerProvider = ConsoleLoggerProvider.ConsoleLoggerProvider;
33
- exports.LoggerFactory = LoggerFactory.LoggerFactory;
34
- exports.LoggerStorage = LoggerFactory.LoggerStorage;
35
- exports.MDC = MDC.MDC;
36
- exports.JSONArray = JSONObject.JSONArray;
37
- exports.JSONObject = JSONObject.JSONObject;
38
- Object.defineProperty(exports, "LoggingLevel", {
39
- enumerable: true,
40
- get: function () { return LoggingLevel.LoggingLevel; }
41
- });
42
- Object.defineProperty(exports, "SortOrder", {
43
- enumerable: true,
44
- get: function () { return SortOrder.SortOrder; }
45
- });
46
- exports.BaseObject = BaseObject.BaseObject;
47
- exports.DateUtil = DateUtil.DateUtil;
48
- //# sourceMappingURL=index.cjs.map
@@ -1,77 +0,0 @@
1
- 'use strict';
2
-
3
- var async_hooks = require('async_hooks');
4
-
5
- /**
6
- * Mapped Diagnostic Context (MDC) implementation using `AsyncLocalStorage`.
7
- * MDC allows associating contextual information (key-value pairs) with the
8
- * current execution context, which can be useful for logging and tracing.
9
- *
10
- * Methods:
11
- * - `get(key: string)`: Retrieves the value associated with the given key in the current context.
12
- * - `put(key: string, value: string)`: Adds or updates a key-value pair in the current context.
13
- * - `putAll(context: ContextMap)`: Adds or updates multiple key-value pairs in the current context.
14
- * - `clear()`: Clears all key-value pairs in the current context.
15
- * - `runWithContext(context: ContextMap, callback: () => T)`: Runs a callback function with the provided context.
16
- */
17
- class MDC {
18
- static { this.storage = new async_hooks.AsyncLocalStorage(); }
19
- /**
20
- * Retrieves the value associated with the given key in the current context.
21
- *
22
- * @param key The key to retrieve the value for.
23
- * @returns The value associated with the key, or `undefined` if not found.
24
- */
25
- static get(key) {
26
- const store = MDC.storage.getStore();
27
- return store ? store[key] : undefined;
28
- }
29
- /**
30
- * Adds or updates a key-value pair in the current context.
31
- *
32
- * @param key The key to add or update.
33
- * @param value The value to associate with the key.
34
- */
35
- static put(key, value) {
36
- let store = MDC.storage.getStore();
37
- if (!store) {
38
- store = {};
39
- }
40
- store[key] = value;
41
- MDC.storage.enterWith(store);
42
- }
43
- /**
44
- * Adds or updates multiple key-value pairs in the current context.
45
- *
46
- * @param context An object containing key-value pairs to add or update.
47
- */
48
- static putAll(context) {
49
- let store = MDC.storage.getStore();
50
- if (!store) {
51
- store = {};
52
- }
53
- Object.entries(context).forEach(([key, value]) => {
54
- store[key] = value;
55
- });
56
- MDC.storage.enterWith(context);
57
- }
58
- /**
59
- * Clears all key-value pairs in the current context.
60
- */
61
- static clear() {
62
- MDC.storage.enterWith({});
63
- }
64
- /**
65
- * Runs a callback function with the provided context.
66
- *
67
- * @param context The context to associate with the callback execution.
68
- * @param callback The callback function to execute.
69
- * @returns The result of the callback function.
70
- */
71
- static runWithContext(context, callback) {
72
- return MDC.storage.run(context, callback);
73
- }
74
- }
75
-
76
- exports.MDC = MDC;
77
- //# sourceMappingURL=MDC.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MDC.cjs","sources":["../../../src/logger/MDC.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'async_hooks';\r\n\r\nexport interface ContextMap {\r\n [key: string]: string;\r\n}\r\n\r\n/**\r\n * Mapped Diagnostic Context (MDC) implementation using `AsyncLocalStorage`.\r\n * MDC allows associating contextual information (key-value pairs) with the\r\n * current execution context, which can be useful for logging and tracing.\r\n *\r\n * Methods:\r\n * - `get(key: string)`: Retrieves the value associated with the given key in the current context.\r\n * - `put(key: string, value: string)`: Adds or updates a key-value pair in the current context.\r\n * - `putAll(context: ContextMap)`: Adds or updates multiple key-value pairs in the current context.\r\n * - `clear()`: Clears all key-value pairs in the current context.\r\n * - `runWithContext(context: ContextMap, callback: () => T)`: Runs a callback function with the provided context.\r\n */\r\nexport class MDC {\r\n private static storage = new AsyncLocalStorage<ContextMap>();\r\n\r\n /**\r\n * Retrieves the value associated with the given key in the current context.\r\n * \r\n * @param key The key to retrieve the value for.\r\n * @returns The value associated with the key, or `undefined` if not found.\r\n */\r\n static get(key: string): string | undefined {\r\n const store = MDC.storage.getStore()!;\r\n return store ? store[key] : undefined;\r\n }\r\n\r\n /**\r\n * Adds or updates a key-value pair in the current context.\r\n * \r\n * @param key The key to add or update.\r\n * @param value The value to associate with the key.\r\n */\r\n static put(key: string, value: string) {\r\n let store: ContextMap | undefined = MDC.storage.getStore();\r\n if (!store) {\r\n store = {};\r\n }\r\n store[key] = value;\r\n MDC.storage.enterWith(store);\r\n }\r\n\r\n /**\r\n * Adds or updates multiple key-value pairs in the current context.\r\n * \r\n * @param context An object containing key-value pairs to add or update.\r\n */\r\n static putAll(context: ContextMap) {\r\n let store: ContextMap | undefined = MDC.storage.getStore();\r\n if (!store) {\r\n store = {};\r\n }\r\n Object.entries(context).forEach(([key, value]) => {\r\n store[key] = value;\r\n });\r\n MDC.storage.enterWith(context);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs in the current context.\r\n */\r\n static clear() {\r\n MDC.storage.enterWith({});\r\n }\r\n\r\n /**\r\n * Runs a callback function with the provided context.\r\n * \r\n * @param context The context to associate with the callback execution.\r\n * @param callback The callback function to execute.\r\n * @returns The result of the callback function.\r\n */\r\n static runWithContext<T>(context: ContextMap, callback: () => T): T {\r\n return MDC.storage.run(context, callback);\r\n }\r\n}\r\n"],"names":["AsyncLocalStorage"],"mappings":";;;;AAMA;;;;;;;;;;;AAWG;MACU,GAAG,CAAA;AACG,IAAA,SAAA,IAAA,CAAA,OAAO,GAAG,IAAIA,6BAAiB,EAAc,CAAC;AAE7D;;;;;AAKG;IACH,OAAO,GAAG,CAAC,GAAW,EAAA;QAClB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAG;AACrC,QAAA,OAAO,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS;;AAGzC;;;;;AAKG;AACH,IAAA,OAAO,GAAG,CAAC,GAAW,EAAE,KAAa,EAAA;QACjC,IAAI,KAAK,GAA2B,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE;QAC1D,IAAI,CAAC,KAAK,EAAE;YACR,KAAK,GAAG,EAAE;;AAEd,QAAA,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK;AAClB,QAAA,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;;AAGhC;;;;AAIG;IACH,OAAO,MAAM,CAAC,OAAmB,EAAA;QAC7B,IAAI,KAAK,GAA2B,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE;QAC1D,IAAI,CAAC,KAAK,EAAE;YACR,KAAK,GAAG,EAAE;;AAEd,QAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC7C,YAAA,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK;AACtB,SAAC,CAAC;AACF,QAAA,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;;AAGlC;;AAEG;AACH,IAAA,OAAO,KAAK,GAAA;AACR,QAAA,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;;AAG7B;;;;;;AAMG;AACH,IAAA,OAAO,cAAc,CAAI,OAAmB,EAAE,QAAiB,EAAA;QAC3D,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC;;;;;;"}
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- var winston = require('winston');
4
- var ClientException = require('../../exceptions/ClientException.cjs');
5
- var LoggingLevel = require('../../types/LoggingLevel.cjs');
6
- var MDC = require('../MDC.cjs');
7
-
8
- const addMdcDataFormat = winston.format((info) => {
9
- info.path = MDC.MDC.get('path');
10
- info.transaction_id = MDC.MDC.get('x-api-transaction-id');
11
- return info;
12
- });
13
- /**
14
- * Implementation of the `LoggerProvider` interface that creates
15
- * a Winston logger configured to log to the console.
16
- */
17
- class ConsoleLoggerProvider {
18
- /**
19
- * Creates a Winston logger instance configured for console logging.
20
- * The logger includes MDC (Mapped Diagnostic Context) data, timestamps,
21
- * and JSON formatting.
22
- *
23
- * @returns A promise that resolves to a Winston logger instance.
24
- * @throws ClientException If an error occurs while creating the logger.
25
- */
26
- async createLogger() {
27
- try {
28
- const logLevel = LoggingLevel.LoggingLevel[(process.env.LOG_LEVEL || 'info').trim().toLowerCase()];
29
- const logger = winston.createLogger({
30
- level: logLevel.toLowerCase(),
31
- format: winston.format.combine(addMdcDataFormat(), winston.format.timestamp(), winston.format.json()),
32
- transports: [new winston.transports.Console()]
33
- });
34
- return logger;
35
- }
36
- catch (error) {
37
- throw new ClientException.ClientException(`Error creating logger`, error, 500);
38
- }
39
- }
40
- }
41
-
42
- exports.ConsoleLoggerProvider = ConsoleLoggerProvider;
43
- //# sourceMappingURL=ConsoleLoggerProvider.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConsoleLoggerProvider.cjs","sources":["../../../../src/logger/factory/ConsoleLoggerProvider.ts"],"sourcesContent":["import winston from 'winston';\r\nimport { ClientException } from '../../exceptions/ClientException.js';\r\nimport { LoggingLevel } from '../../types/LoggingLevel.js';\r\nimport { MDC } from '../MDC.js';\r\nimport { LoggerProvider } from './LoggerProvider.js';\r\n\r\nconst addMdcDataFormat = winston.format((info) => {\r\n info.path = MDC.get('path');\r\n info.transaction_id = MDC.get('x-api-transaction-id');\r\n return info;\r\n});\r\n\r\n/**\r\n * Implementation of the `LoggerProvider` interface that creates\r\n * a Winston logger configured to log to the console.\r\n */\r\nexport class ConsoleLoggerProvider implements LoggerProvider {\r\n\r\n /**\r\n * Creates a Winston logger instance configured for console logging.\r\n * The logger includes MDC (Mapped Diagnostic Context) data, timestamps,\r\n * and JSON formatting.\r\n *\r\n * @returns A promise that resolves to a Winston logger instance.\r\n * @throws ClientException If an error occurs while creating the logger.\r\n */\r\n async createLogger(): Promise<winston.Logger> {\r\n try {\r\n const logLevel = LoggingLevel[(process.env.LOG_LEVEL || 'info').trim().toLowerCase()];\r\n const logger = winston.createLogger({\r\n level: logLevel.toLowerCase(),\r\n format: winston.format.combine(\r\n addMdcDataFormat(),\r\n winston.format.timestamp(),\r\n winston.format.json()\r\n ),\r\n transports: [new winston.transports.Console()]\r\n });\r\n return logger;\r\n } catch (error) {\r\n throw new ClientException(`Error creating logger`, error, 500);\r\n }\r\n }\r\n}"],"names":["MDC","LoggingLevel","ClientException"],"mappings":";;;;;;;AAMA,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,KAAI;IAC7C,IAAI,CAAC,IAAI,GAAGA,OAAG,CAAC,GAAG,CAAC,MAAM,CAAC;IAC3B,IAAI,CAAC,cAAc,GAAGA,OAAG,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACrD,IAAA,OAAO,IAAI;AACf,CAAC,CAAC;AAEF;;;AAGG;MACU,qBAAqB,CAAA;AAE9B;;;;;;;AAOG;AACH,IAAA,MAAM,YAAY,GAAA;AACd,QAAA,IAAI;YACA,MAAM,QAAQ,GAAGC,yBAAY,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACrF,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;AAChC,gBAAA,KAAK,EAAE,QAAQ,CAAC,WAAW,EAAE;gBAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC1B,gBAAgB,EAAE,EAClB,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAC1B,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CACxB;gBACD,UAAU,EAAE,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE;AAChD,aAAA,CAAC;AACF,YAAA,OAAO,MAAM;;QACf,OAAO,KAAK,EAAE;YACZ,MAAM,IAAIC,+BAAe,CAAC,CAAA,qBAAA,CAAuB,EAAE,KAAK,EAAE,GAAG,CAAC;;;AAGzE;;;;"}
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * A factory class for managing logger instances.
5
- * Provides methods to retrieve and store loggers in a shared storage.
6
- */
7
- const LoggerStorage = new Map();
8
- class LoggerFactory {
9
- /**
10
- * Retrieves a logger instance by its name.
11
- *
12
- * @param loggerName The name of the logger to retrieve.
13
- * @returns The logger instance if found, otherwise `undefined`.
14
- */
15
- static getLogger(loggerName) {
16
- return LoggerStorage.get(loggerName);
17
- }
18
- /**
19
- * Stores a logger instance with the specified name.
20
- *
21
- * @param loggerName The name to associate with the logger.
22
- * @param logger The logger instance to store.
23
- */
24
- static setLogger(loggerName, logger) {
25
- LoggerStorage.set(loggerName, logger);
26
- }
27
- }
28
-
29
- exports.LoggerFactory = LoggerFactory;
30
- exports.LoggerStorage = LoggerStorage;
31
- //# sourceMappingURL=LoggerFactory.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoggerFactory.cjs","sources":["../../../../src/logger/factory/LoggerFactory.ts"],"sourcesContent":["import winston, { Logger } from 'winston';\r\n\r\n/**\r\n * A factory class for managing logger instances.\r\n * Provides methods to retrieve and store loggers in a shared storage.\r\n */\r\nexport const LoggerStorage: Map<string, winston.Logger> = new Map<string, winston.Logger>();\r\n\r\nexport class LoggerFactory {\r\n\r\n /**\r\n * Retrieves a logger instance by its name.\r\n * \r\n * @param loggerName The name of the logger to retrieve.\r\n * @returns The logger instance if found, otherwise `undefined`.\r\n */\r\n static getLogger(loggerName: string): winston.Logger | undefined {\r\n return LoggerStorage.get(loggerName);\r\n }\r\n\r\n /**\r\n * Stores a logger instance with the specified name.\r\n * \r\n * @param loggerName The name to associate with the logger.\r\n * @param logger The logger instance to store.\r\n */\r\n static setLogger(loggerName: string, logger: Logger) {\r\n LoggerStorage.set(loggerName, logger);\r\n }\r\n}"],"names":[],"mappings":";;AAEA;;;AAGG;AACU,MAAA,aAAa,GAAgC,IAAI,GAAG;MAEpD,aAAa,CAAA;AAEtB;;;;;AAKG;IACH,OAAO,SAAS,CAAC,UAAkB,EAAA;AAC/B,QAAA,OAAO,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC;;AAGxC;;;;;AAKG;AACH,IAAA,OAAO,SAAS,CAAC,UAAkB,EAAE,MAAc,EAAA;AAC/C,QAAA,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC;;AAE5C;;;;;"}
@@ -1,13 +0,0 @@
1
- import { BaseException } from './BaseException.js';
2
-
3
- /**
4
- * Exception thrown when an operation is attempted on a `null` or `undefined` value.
5
- */
6
- class NullPointerException extends BaseException {
7
- constructor(message, cause) {
8
- super(message, cause, 500);
9
- }
10
- }
11
-
12
- export { NullPointerException };
13
- //# sourceMappingURL=NullPointerException.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NullPointerException.js","sources":["../../../src/exceptions/NullPointerException.ts"],"sourcesContent":["import { BaseException } from \"./BaseException.js\";\r\n\r\n/**\r\n * Exception thrown when an operation is attempted on a `null` or `undefined` value.\r\n */\r\nexport class NullPointerException extends BaseException {\r\n\r\n constructor(message: string, cause?: unknown) {\r\n super(message, cause, 500);\r\n }\r\n}\r\n\r\n"],"names":[],"mappings":";;AAEA;;AAEG;AACG,MAAO,oBAAqB,SAAQ,aAAa,CAAA;IAEnD,WAAY,CAAA,OAAe,EAAE,KAAe,EAAA;AACxC,QAAA,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;;AAEjC;;;;"}
package/dist/esm/index.js DELETED
@@ -1,18 +0,0 @@
1
- export { BadRequestException } from './exceptions/BadRequestException.js';
2
- export { BaseException } from './exceptions/BaseException.js';
3
- export { ClientException } from './exceptions/ClientException.js';
4
- export { ForbiddenAccessException } from './exceptions/ForbiddenAccessException.js';
5
- export { HTTPException } from './exceptions/HTTPException.js';
6
- export { IllegalArgumentException } from './exceptions/IllegalArgumentException.js';
7
- export { UnauthorizedException } from './exceptions/UnauthorizedException.js';
8
- export { NullPointerException } from './exceptions/NullPointerException.js';
9
- export { ConverterException } from './exceptions/ConverterException.js';
10
- export { ConsoleLoggerProvider } from './logger/factory/ConsoleLoggerProvider.js';
11
- export { LoggerFactory, LoggerStorage } from './logger/factory/LoggerFactory.js';
12
- export { MDC } from './logger/MDC.js';
13
- export { JSONArray, JSONObject } from './types/JSONObject.js';
14
- export { LoggingLevel } from './types/LoggingLevel.js';
15
- export { SortOrder } from './types/SortOrder.js';
16
- export { BaseObject } from './beans/BaseObject.js';
17
- export { DateUtil } from './utils/date/DateUtil.js';
18
- //# sourceMappingURL=index.js.map
@@ -1,75 +0,0 @@
1
- import { AsyncLocalStorage } from 'async_hooks';
2
-
3
- /**
4
- * Mapped Diagnostic Context (MDC) implementation using `AsyncLocalStorage`.
5
- * MDC allows associating contextual information (key-value pairs) with the
6
- * current execution context, which can be useful for logging and tracing.
7
- *
8
- * Methods:
9
- * - `get(key: string)`: Retrieves the value associated with the given key in the current context.
10
- * - `put(key: string, value: string)`: Adds or updates a key-value pair in the current context.
11
- * - `putAll(context: ContextMap)`: Adds or updates multiple key-value pairs in the current context.
12
- * - `clear()`: Clears all key-value pairs in the current context.
13
- * - `runWithContext(context: ContextMap, callback: () => T)`: Runs a callback function with the provided context.
14
- */
15
- class MDC {
16
- static { this.storage = new AsyncLocalStorage(); }
17
- /**
18
- * Retrieves the value associated with the given key in the current context.
19
- *
20
- * @param key The key to retrieve the value for.
21
- * @returns The value associated with the key, or `undefined` if not found.
22
- */
23
- static get(key) {
24
- const store = MDC.storage.getStore();
25
- return store ? store[key] : undefined;
26
- }
27
- /**
28
- * Adds or updates a key-value pair in the current context.
29
- *
30
- * @param key The key to add or update.
31
- * @param value The value to associate with the key.
32
- */
33
- static put(key, value) {
34
- let store = MDC.storage.getStore();
35
- if (!store) {
36
- store = {};
37
- }
38
- store[key] = value;
39
- MDC.storage.enterWith(store);
40
- }
41
- /**
42
- * Adds or updates multiple key-value pairs in the current context.
43
- *
44
- * @param context An object containing key-value pairs to add or update.
45
- */
46
- static putAll(context) {
47
- let store = MDC.storage.getStore();
48
- if (!store) {
49
- store = {};
50
- }
51
- Object.entries(context).forEach(([key, value]) => {
52
- store[key] = value;
53
- });
54
- MDC.storage.enterWith(context);
55
- }
56
- /**
57
- * Clears all key-value pairs in the current context.
58
- */
59
- static clear() {
60
- MDC.storage.enterWith({});
61
- }
62
- /**
63
- * Runs a callback function with the provided context.
64
- *
65
- * @param context The context to associate with the callback execution.
66
- * @param callback The callback function to execute.
67
- * @returns The result of the callback function.
68
- */
69
- static runWithContext(context, callback) {
70
- return MDC.storage.run(context, callback);
71
- }
72
- }
73
-
74
- export { MDC };
75
- //# sourceMappingURL=MDC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MDC.js","sources":["../../../src/logger/MDC.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'async_hooks';\r\n\r\nexport interface ContextMap {\r\n [key: string]: string;\r\n}\r\n\r\n/**\r\n * Mapped Diagnostic Context (MDC) implementation using `AsyncLocalStorage`.\r\n * MDC allows associating contextual information (key-value pairs) with the\r\n * current execution context, which can be useful for logging and tracing.\r\n *\r\n * Methods:\r\n * - `get(key: string)`: Retrieves the value associated with the given key in the current context.\r\n * - `put(key: string, value: string)`: Adds or updates a key-value pair in the current context.\r\n * - `putAll(context: ContextMap)`: Adds or updates multiple key-value pairs in the current context.\r\n * - `clear()`: Clears all key-value pairs in the current context.\r\n * - `runWithContext(context: ContextMap, callback: () => T)`: Runs a callback function with the provided context.\r\n */\r\nexport class MDC {\r\n private static storage = new AsyncLocalStorage<ContextMap>();\r\n\r\n /**\r\n * Retrieves the value associated with the given key in the current context.\r\n * \r\n * @param key The key to retrieve the value for.\r\n * @returns The value associated with the key, or `undefined` if not found.\r\n */\r\n static get(key: string): string | undefined {\r\n const store = MDC.storage.getStore()!;\r\n return store ? store[key] : undefined;\r\n }\r\n\r\n /**\r\n * Adds or updates a key-value pair in the current context.\r\n * \r\n * @param key The key to add or update.\r\n * @param value The value to associate with the key.\r\n */\r\n static put(key: string, value: string) {\r\n let store: ContextMap | undefined = MDC.storage.getStore();\r\n if (!store) {\r\n store = {};\r\n }\r\n store[key] = value;\r\n MDC.storage.enterWith(store);\r\n }\r\n\r\n /**\r\n * Adds or updates multiple key-value pairs in the current context.\r\n * \r\n * @param context An object containing key-value pairs to add or update.\r\n */\r\n static putAll(context: ContextMap) {\r\n let store: ContextMap | undefined = MDC.storage.getStore();\r\n if (!store) {\r\n store = {};\r\n }\r\n Object.entries(context).forEach(([key, value]) => {\r\n store[key] = value;\r\n });\r\n MDC.storage.enterWith(context);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs in the current context.\r\n */\r\n static clear() {\r\n MDC.storage.enterWith({});\r\n }\r\n\r\n /**\r\n * Runs a callback function with the provided context.\r\n * \r\n * @param context The context to associate with the callback execution.\r\n * @param callback The callback function to execute.\r\n * @returns The result of the callback function.\r\n */\r\n static runWithContext<T>(context: ContextMap, callback: () => T): T {\r\n return MDC.storage.run(context, callback);\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAMA;;;;;;;;;;;AAWG;MACU,GAAG,CAAA;AACG,IAAA,SAAA,IAAA,CAAA,OAAO,GAAG,IAAI,iBAAiB,EAAc,CAAC;AAE7D;;;;;AAKG;IACH,OAAO,GAAG,CAAC,GAAW,EAAA;QAClB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAG;AACrC,QAAA,OAAO,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS;;AAGzC;;;;;AAKG;AACH,IAAA,OAAO,GAAG,CAAC,GAAW,EAAE,KAAa,EAAA;QACjC,IAAI,KAAK,GAA2B,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE;QAC1D,IAAI,CAAC,KAAK,EAAE;YACR,KAAK,GAAG,EAAE;;AAEd,QAAA,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK;AAClB,QAAA,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;;AAGhC;;;;AAIG;IACH,OAAO,MAAM,CAAC,OAAmB,EAAA;QAC7B,IAAI,KAAK,GAA2B,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE;QAC1D,IAAI,CAAC,KAAK,EAAE;YACR,KAAK,GAAG,EAAE;;AAEd,QAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC7C,YAAA,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK;AACtB,SAAC,CAAC;AACF,QAAA,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;;AAGlC;;AAEG;AACH,IAAA,OAAO,KAAK,GAAA;AACR,QAAA,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;;AAG7B;;;;;;AAMG;AACH,IAAA,OAAO,cAAc,CAAI,OAAmB,EAAE,QAAiB,EAAA;QAC3D,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC;;;;;;"}
@@ -1,41 +0,0 @@
1
- import winston from 'winston';
2
- import { ClientException } from '../../exceptions/ClientException.js';
3
- import { LoggingLevel } from '../../types/LoggingLevel.js';
4
- import { MDC } from '../MDC.js';
5
-
6
- const addMdcDataFormat = winston.format((info) => {
7
- info.path = MDC.get('path');
8
- info.transaction_id = MDC.get('x-api-transaction-id');
9
- return info;
10
- });
11
- /**
12
- * Implementation of the `LoggerProvider` interface that creates
13
- * a Winston logger configured to log to the console.
14
- */
15
- class ConsoleLoggerProvider {
16
- /**
17
- * Creates a Winston logger instance configured for console logging.
18
- * The logger includes MDC (Mapped Diagnostic Context) data, timestamps,
19
- * and JSON formatting.
20
- *
21
- * @returns A promise that resolves to a Winston logger instance.
22
- * @throws ClientException If an error occurs while creating the logger.
23
- */
24
- async createLogger() {
25
- try {
26
- const logLevel = LoggingLevel[(process.env.LOG_LEVEL || 'info').trim().toLowerCase()];
27
- const logger = winston.createLogger({
28
- level: logLevel.toLowerCase(),
29
- format: winston.format.combine(addMdcDataFormat(), winston.format.timestamp(), winston.format.json()),
30
- transports: [new winston.transports.Console()]
31
- });
32
- return logger;
33
- }
34
- catch (error) {
35
- throw new ClientException(`Error creating logger`, error, 500);
36
- }
37
- }
38
- }
39
-
40
- export { ConsoleLoggerProvider };
41
- //# sourceMappingURL=ConsoleLoggerProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConsoleLoggerProvider.js","sources":["../../../../src/logger/factory/ConsoleLoggerProvider.ts"],"sourcesContent":["import winston from 'winston';\r\nimport { ClientException } from '../../exceptions/ClientException.js';\r\nimport { LoggingLevel } from '../../types/LoggingLevel.js';\r\nimport { MDC } from '../MDC.js';\r\nimport { LoggerProvider } from './LoggerProvider.js';\r\n\r\nconst addMdcDataFormat = winston.format((info) => {\r\n info.path = MDC.get('path');\r\n info.transaction_id = MDC.get('x-api-transaction-id');\r\n return info;\r\n});\r\n\r\n/**\r\n * Implementation of the `LoggerProvider` interface that creates\r\n * a Winston logger configured to log to the console.\r\n */\r\nexport class ConsoleLoggerProvider implements LoggerProvider {\r\n\r\n /**\r\n * Creates a Winston logger instance configured for console logging.\r\n * The logger includes MDC (Mapped Diagnostic Context) data, timestamps,\r\n * and JSON formatting.\r\n *\r\n * @returns A promise that resolves to a Winston logger instance.\r\n * @throws ClientException If an error occurs while creating the logger.\r\n */\r\n async createLogger(): Promise<winston.Logger> {\r\n try {\r\n const logLevel = LoggingLevel[(process.env.LOG_LEVEL || 'info').trim().toLowerCase()];\r\n const logger = winston.createLogger({\r\n level: logLevel.toLowerCase(),\r\n format: winston.format.combine(\r\n addMdcDataFormat(),\r\n winston.format.timestamp(),\r\n winston.format.json()\r\n ),\r\n transports: [new winston.transports.Console()]\r\n });\r\n return logger;\r\n } catch (error) {\r\n throw new ClientException(`Error creating logger`, error, 500);\r\n }\r\n }\r\n}"],"names":[],"mappings":";;;;;AAMA,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,KAAI;IAC7C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;IAC3B,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACrD,IAAA,OAAO,IAAI;AACf,CAAC,CAAC;AAEF;;;AAGG;MACU,qBAAqB,CAAA;AAE9B;;;;;;;AAOG;AACH,IAAA,MAAM,YAAY,GAAA;AACd,QAAA,IAAI;YACA,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACrF,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;AAChC,gBAAA,KAAK,EAAE,QAAQ,CAAC,WAAW,EAAE;gBAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC1B,gBAAgB,EAAE,EAClB,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAC1B,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CACxB;gBACD,UAAU,EAAE,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE;AAChD,aAAA,CAAC;AACF,YAAA,OAAO,MAAM;;QACf,OAAO,KAAK,EAAE;YACZ,MAAM,IAAI,eAAe,CAAC,CAAA,qBAAA,CAAuB,EAAE,KAAK,EAAE,GAAG,CAAC;;;AAGzE;;;;"}
@@ -1,28 +0,0 @@
1
- /**
2
- * A factory class for managing logger instances.
3
- * Provides methods to retrieve and store loggers in a shared storage.
4
- */
5
- const LoggerStorage = new Map();
6
- class LoggerFactory {
7
- /**
8
- * Retrieves a logger instance by its name.
9
- *
10
- * @param loggerName The name of the logger to retrieve.
11
- * @returns The logger instance if found, otherwise `undefined`.
12
- */
13
- static getLogger(loggerName) {
14
- return LoggerStorage.get(loggerName);
15
- }
16
- /**
17
- * Stores a logger instance with the specified name.
18
- *
19
- * @param loggerName The name to associate with the logger.
20
- * @param logger The logger instance to store.
21
- */
22
- static setLogger(loggerName, logger) {
23
- LoggerStorage.set(loggerName, logger);
24
- }
25
- }
26
-
27
- export { LoggerFactory, LoggerStorage };
28
- //# sourceMappingURL=LoggerFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoggerFactory.js","sources":["../../../../src/logger/factory/LoggerFactory.ts"],"sourcesContent":["import winston, { Logger } from 'winston';\r\n\r\n/**\r\n * A factory class for managing logger instances.\r\n * Provides methods to retrieve and store loggers in a shared storage.\r\n */\r\nexport const LoggerStorage: Map<string, winston.Logger> = new Map<string, winston.Logger>();\r\n\r\nexport class LoggerFactory {\r\n\r\n /**\r\n * Retrieves a logger instance by its name.\r\n * \r\n * @param loggerName The name of the logger to retrieve.\r\n * @returns The logger instance if found, otherwise `undefined`.\r\n */\r\n static getLogger(loggerName: string): winston.Logger | undefined {\r\n return LoggerStorage.get(loggerName);\r\n }\r\n\r\n /**\r\n * Stores a logger instance with the specified name.\r\n * \r\n * @param loggerName The name to associate with the logger.\r\n * @param logger The logger instance to store.\r\n */\r\n static setLogger(loggerName: string, logger: Logger) {\r\n LoggerStorage.set(loggerName, logger);\r\n }\r\n}"],"names":[],"mappings":"AAEA;;;AAGG;AACU,MAAA,aAAa,GAAgC,IAAI,GAAG;MAEpD,aAAa,CAAA;AAEtB;;;;;AAKG;IACH,OAAO,SAAS,CAAC,UAAkB,EAAA;AAC/B,QAAA,OAAO,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC;;AAGxC;;;;;AAKG;AACH,IAAA,OAAO,SAAS,CAAC,UAAkB,EAAE,MAAc,EAAA;AAC/C,QAAA,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC;;AAE5C;;;;"}
@@ -1,10 +0,0 @@
1
- import { BaseException } from './BaseException.js';
2
-
3
- /**
4
- * Exception thrown when an operation is attempted on a `null` or `undefined` value.
5
- */
6
- declare class NullPointerException extends BaseException {
7
- constructor(message: string, cause?: unknown);
8
- }
9
-
10
- export { NullPointerException };