@creator.co/wapi 1.2.5 → 1.2.6

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 (115) hide show
  1. package/README.md +216 -5
  2. package/dist/index.d.ts +15 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +6 -1
  5. package/dist/src/API/Request.d.ts +45 -82
  6. package/dist/src/API/Request.js +49 -77
  7. package/dist/src/API/Request.js.map +1 -1
  8. package/dist/src/API/Response.d.ts +94 -163
  9. package/dist/src/API/Response.js +101 -161
  10. package/dist/src/API/Response.js.map +1 -1
  11. package/dist/src/API/Utils.d.ts +21 -42
  12. package/dist/src/API/Utils.js +22 -43
  13. package/dist/src/API/Utils.js.map +1 -1
  14. package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
  15. package/dist/src/BaseEvent/EventProcessor.js +30 -38
  16. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  17. package/dist/src/BaseEvent/Process.d.ts +20 -43
  18. package/dist/src/BaseEvent/Process.js +16 -27
  19. package/dist/src/BaseEvent/Process.js.map +1 -1
  20. package/dist/src/BaseEvent/Transaction.d.ts +94 -2
  21. package/dist/src/BaseEvent/Transaction.js +49 -4
  22. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  23. package/dist/src/Config/Configuration.d.ts +48 -66
  24. package/dist/src/Config/Configuration.js +25 -42
  25. package/dist/src/Config/Configuration.js.map +1 -1
  26. package/dist/src/Config/EnvironmentVar.d.ts +30 -57
  27. package/dist/src/Config/EnvironmentVar.js +28 -41
  28. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  29. package/dist/src/Crypto/Crypto.d.ts +17 -35
  30. package/dist/src/Crypto/Crypto.js +12 -21
  31. package/dist/src/Crypto/Crypto.js.map +1 -1
  32. package/dist/src/Crypto/JWT.d.ts +21 -32
  33. package/dist/src/Crypto/JWT.js +14 -22
  34. package/dist/src/Crypto/JWT.js.map +1 -1
  35. package/dist/src/Globals.d.ts +26 -94
  36. package/dist/src/Globals.js +26 -95
  37. package/dist/src/Globals.js.map +1 -1
  38. package/dist/src/Logger/Logger.d.ts +82 -105
  39. package/dist/src/Logger/Logger.js +111 -136
  40. package/dist/src/Logger/Logger.js.map +1 -1
  41. package/dist/src/Mailer/Mailer.d.ts +39 -75
  42. package/dist/src/Mailer/Mailer.js +36 -65
  43. package/dist/src/Mailer/Mailer.js.map +1 -1
  44. package/dist/src/Publisher/Publisher.d.ts +17 -25
  45. package/dist/src/Publisher/Publisher.js +21 -32
  46. package/dist/src/Publisher/Publisher.js.map +1 -1
  47. package/dist/src/Server/RouteResolver.d.ts +14 -22
  48. package/dist/src/Server/RouteResolver.js +21 -34
  49. package/dist/src/Server/RouteResolver.js.map +1 -1
  50. package/dist/src/Server/Router.d.ts +72 -51
  51. package/dist/src/Server/Router.js +8 -17
  52. package/dist/src/Server/Router.js.map +1 -1
  53. package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
  54. package/dist/src/Server/lib/ContainerServer.js +13 -28
  55. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  56. package/dist/src/Server/lib/Server.d.ts +17 -32
  57. package/dist/src/Server/lib/Server.js +18 -28
  58. package/dist/src/Server/lib/Server.js.map +1 -1
  59. package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
  60. package/dist/src/Server/lib/container/GenericHandler.js +16 -3
  61. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  62. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
  63. package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
  64. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  65. package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
  66. package/dist/src/Server/lib/container/HealthHandler.js +6 -0
  67. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  68. package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
  69. package/dist/src/Server/lib/container/Proxy.js +49 -50
  70. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  71. package/dist/src/Server/lib/container/Utils.d.ts +6 -10
  72. package/dist/src/Server/lib/container/Utils.js +6 -10
  73. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  74. package/dist/src/Validation/Validator.d.ts +9 -13
  75. package/dist/src/Validation/Validator.js +8 -12
  76. package/dist/src/Validation/Validator.js.map +1 -1
  77. package/index.ts +15 -0
  78. package/package.json +6 -1
  79. package/src/API/Request.ts +66 -84
  80. package/src/API/Response.ts +144 -203
  81. package/src/API/Utils.ts +28 -44
  82. package/src/BaseEvent/EventProcessor.ts +52 -77
  83. package/src/BaseEvent/Process.ts +27 -52
  84. package/src/BaseEvent/Transaction.ts +100 -10
  85. package/src/Config/Configuration.ts +59 -76
  86. package/src/Config/EnvironmentVar.ts +39 -62
  87. package/src/Crypto/Crypto.ts +20 -36
  88. package/src/Crypto/JWT.ts +31 -35
  89. package/src/Globals.ts +28 -96
  90. package/src/Logger/Logger.ts +141 -160
  91. package/src/Mailer/Mailer.ts +43 -76
  92. package/src/Publisher/Publisher.ts +31 -40
  93. package/src/Server/RouteResolver.ts +31 -52
  94. package/src/Server/Router.ts +75 -54
  95. package/src/Server/lib/ContainerServer.ts +20 -32
  96. package/src/Server/lib/Server.ts +19 -34
  97. package/src/Server/lib/container/GenericHandler.ts +17 -3
  98. package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
  99. package/src/Server/lib/container/HealthHandler.ts +6 -0
  100. package/src/Server/lib/container/Proxy.ts +37 -57
  101. package/src/Server/lib/container/Utils.ts +7 -10
  102. package/src/Validation/Validator.ts +11 -13
  103. package/tests/API/Response.test.ts +55 -56
  104. package/tests/BaseEvent/EventProcessor.test.ts +49 -50
  105. package/tests/BaseEvent/Process.test.ts +2 -2
  106. package/tests/BaseEvent/Transaction.test.ts +48 -49
  107. package/tests/Config/Config.test.ts +27 -27
  108. package/tests/Config/EnvironmentVar.test.ts +54 -18
  109. package/tests/Publisher/Publisher.test.ts +3 -3
  110. package/tests/Server/lib/ContainerServer.test.ts +21 -22
  111. package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
  112. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
  113. package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
  114. package/tests/Server/lib/container/Proxy.test.ts +37 -35
  115. package/tsconfig.json +1 -1
package/src/Globals.ts CHANGED
@@ -4,168 +4,100 @@ import Utils from './API/Utils'
4
4
 
5
5
  // important for dev env to load .env file
6
6
  dotenv.config()
7
+
7
8
  /**
8
- * Description placeholder
9
- *
10
- * @export
11
- * @class Globals
12
- * @typedef {Globals}
9
+ * Class containing global constants and configurations for the application.
13
10
  */
14
11
  export default class Globals {
15
12
  /**
16
- * Description placeholder
17
- *
18
- * @public
19
- * @static
20
- * @type {string}
13
+ * A constant string representing an error message for input validation failure.
21
14
  */
22
15
  public static ErrorResponseValidationFail = 'Input validation failed: ' //400
23
16
  /**
24
- * Description placeholder
25
- *
26
- * @public
27
- * @static
28
- * @type {string}
17
+ * A constant string representing an error response for an invalid server response.
29
18
  */
30
19
  public static ErrorResponseInvalidServerResponse = 'No valid response, this is a system error.' //400
31
20
  /**
32
- * Description placeholder
33
- *
34
- * @public
35
- * @static
36
- * @type {string}
21
+ * The error message for an unhandled error when processing a request.
37
22
  */
38
23
  public static ErrorResponseUnhandledError = 'Unhandled error when processing request.' //400
39
24
  /**
40
- * Description placeholder
41
- *
42
- * @public
43
- * @static
44
- * @type {string}
25
+ * A static string representing an error response when there are no records to be processed.
45
26
  */
46
27
  public static ErrorResponseNoRecords = 'No events to be processed.' //400
47
28
  /**
48
- * Description placeholder
49
- *
50
- * @public
51
- * @static
29
+ * Represents an error code for a missing parameter.
52
30
  * @type {string}
53
31
  */
54
32
  public static ErrorCode_MissingParam = 'MISSING_PARAM'
55
33
  /**
56
- * Description placeholder
57
- *
58
- * @public
59
- * @static
34
+ * Represents an error code for invalid input.
60
35
  * @type {string}
61
36
  */
62
37
  public static ErrorCode_InvalidInput = 'INVALID_INPUT'
63
38
  /**
64
- * Description placeholder
65
- *
66
- * @public
67
- * @static
39
+ * Represents an error code for an API error.
68
40
  * @type {string}
69
41
  */
70
42
  public static ErrorCode_APIError = 'API_ERROR'
71
43
  /**
72
- * Description placeholder
73
- *
74
- * @public
75
- * @static
44
+ * Represents the error code for when there are no records found.
76
45
  * @type {string}
77
46
  */
78
47
  public static ErrorCode_NoRecords = 'EMPTY_EVENT'
79
48
 
80
49
  /**
81
- * Description placeholder
82
- *
83
- * @public
84
- * @static
85
- * @type {*}
50
+ * Retrieves the default port number for HTTP listeners.
51
+ * The port number is obtained from the environment variable "PORT" and parsed as an integer.
52
+ * If the environment variable is not set or cannot be parsed as an integer, the default port number 9000 is used.
53
+ * @returns {number} - The default port number for HTTP listeners.
86
54
  */
87
55
  public static Listener_HTTP_DefaultPort = Utils.parseIntNullIfNaN(process.env.PORT) || 9000
88
-
89
56
  /**
90
- * Description placeholder
91
- *
92
- * @public
93
- * @static
94
- * @type {string}
57
+ * The default host for the HTTP listener.
95
58
  */
96
59
  public static Listener_HTTP_DefaultHost = 'localhost'
97
60
  /**
98
- * Description placeholder
99
- *
100
- * @public
101
- * @static
61
+ * The HTTP proxy route listener for all routes.
102
62
  * @type {string}
103
63
  */
104
64
  public static Listener_HTTP_ProxyRoute = '*'
105
65
  /**
106
- * Description placeholder
107
- *
108
- * @public
109
- * @static
110
- * @type {*}
66
+ * Retrieves the default timeout value for HTTP listeners.
67
+ * @returns {number} The default timeout value in milliseconds.
111
68
  */
112
69
  public static Listener_HTTP_DefaultTimeout = Utils.parseIntNullIfNaN(process.env.TIMEOUT) || 30000
113
70
  /**
114
- * Description placeholder
115
- *
116
- * @public
117
- * @static
118
- * @type {*}
71
+ * The default health check route for the HTTP listener.
72
+ * @type {string}
119
73
  */
120
74
  public static Listener_HTTP_DefaultHealthCheckRoute = process.env.HEALTH_ROUTE || '/health'
121
- //Resps
75
+
122
76
  /**
123
- * Description placeholder
124
- *
125
- * @public
126
- * @static
127
- * @type {string}
77
+ * The response message for an exception that occurred during request execution in the Proxy.
128
78
  */
129
79
  public static Resp_MSG_EXCEPTION = '[Proxy]: Exception during request execution!'
130
80
  /**
131
- * Description placeholder
132
- *
133
- * @public
134
- * @static
135
- * @type {string}
81
+ * The response code for an exception that occurred during execution.
136
82
  */
137
83
  public static Resp_CODE_EXCEPTION = 'EXEC_EXCEPTION'
138
84
  /**
139
- * Description placeholder
140
- *
141
- * @public
142
- * @static
143
- * @type {number}
85
+ * The HTTP response status code for an exception scenario.
144
86
  */
145
87
  public static Resp_STATUSCODE_EXCEPTION = 502
146
88
 
147
89
  /**
148
- * Description placeholder
149
- *
150
- * @public
151
- * @static
152
- * @type {string}
90
+ * The error message for an invalid response from the server.
153
91
  */
154
92
  public static Resp_MSG_INVALIDRESP = '[Proxy]: Invalid response from server!'
155
93
  /**
156
- * Description placeholder
157
- *
158
- * @public
159
- * @static
160
- * @type {string}
94
+ * Represents the response code for an invalid response.
161
95
  */
162
96
  public static Resp_CODE_INVALIDRESP = 'EMPTY_RESPONSE'
163
97
  /**
164
- * Description placeholder
165
- *
166
- * @public
167
- * @static
98
+ * The HTTP response status code for an invalid response.
168
99
  * @type {number}
100
+ * @default 400
169
101
  */
170
102
  public static Resp_STATUSCODE_INVALIDRESP = 400
171
103
  }
@@ -2,14 +2,15 @@ import * as abind from 'abind'
2
2
  import * as stringify from 'json-stringify-safe'
3
3
  import * as stackTrace from 'stack-trace'
4
4
 
5
- //
6
5
  import Utils from '../API/Utils'
7
- //
6
+
8
7
  /**
9
- * ${1:Description placeholder}
10
- *
11
- * @export
12
- * @enum {number}
8
+ * Enumeration of log levels.
9
+ * @enum {string}
10
+ * @property {string} DEBUG - Debug log level.
11
+ * @property {string} INFO - Info log level.
12
+ * @property {string} WARN - Warning log level.
13
+ * @property {string} ERROR - Error log level.
13
14
  */
14
15
  export enum LOG_LEVELS {
15
16
  DEBUG = 'DEBUG',
@@ -18,22 +19,22 @@ export enum LOG_LEVELS {
18
19
  ERROR = 'ERROR',
19
20
  }
20
21
  /**
21
- * ${1:Description placeholder}
22
- *
23
- * @type {*}
22
+ * A constant that represents the console object to be used for logging.
23
+ * If the console object has a property named 'notGlobalLogger', it is assumed
24
+ * to be a custom logger and the 'origin' property is used as the console object.
25
+ * Otherwise, the global console object is used.
26
+ * @type {Console}
24
27
  */
25
28
  const PURE_CONSOLE = console['notGlobalLogger'] ? console['origin'] : console
26
29
  /**
27
- * ${1:Description placeholder}
28
- *
29
- * @type {*}
30
+ * The default log function that is used for logging messages.
31
+ * @type {Function}
30
32
  */
31
33
  const DEFAULT_LOG_FUNCTION = PURE_CONSOLE.log.bind(PURE_CONSOLE)
32
- //
34
+
33
35
  /**
34
- * ${1:Description placeholder}
35
- *
36
- * @type {{}\}
36
+ * An array of sensitive strings that should be blacklisted or excluded from certain operations.
37
+ * This array includes strings such as 'password', 'phonenumber', 'resetCode', etc.
37
38
  */
38
39
  const blacklist = [
39
40
  'password',
@@ -49,206 +50,191 @@ const blacklist = [
49
50
  'UserCode',
50
51
  'paymentMethodNonce',
51
52
  ]
52
- //
53
+
53
54
  /**
54
- * ${1:Description placeholder}
55
- *
56
- * @export
57
- * @typedef {LoggerConfig}
55
+ * Configuration options for the logger.
56
+ * @typedef {Object} LoggerConfig
57
+ * @property {boolean | Array<string>} [sensitiveFilteringKeywords] - Specifies whether to filter sensitive keywords in log messages. Can be a boolean value or an array of strings.
58
+ * @property {LOG_LEVELS | string} [logLevel] - The log level to use for logging. Can be one of the predefined log levels or a custom string value.
58
59
  */
59
60
  export type LoggerConfig = {
60
61
  sensitiveFilteringKeywords?: boolean | Array<string>
61
62
  logLevel?: LOG_LEVELS | string
62
63
  }
63
- //
64
+
64
65
  /**
65
- * ${1:Description placeholder}
66
- *
67
- * @export
68
- * @class Logger
69
- * @typedef {Logger}
66
+ * Logger class for logging messages with different log levels.
70
67
  */
71
68
  export default class Logger {
72
69
  /**
73
- * ${1:Description placeholder}
74
- *
75
- * @private
76
- * @type {?LoggerConfig}
70
+ * The optional configuration object for the logger.
77
71
  */
78
- private _config?: LoggerConfig
72
+ private config?: LoggerConfig
79
73
  /**
80
- * ${1:Description placeholder}
81
- *
82
- * @private
74
+ * Private property representing the transaction ID.
83
75
  * @type {string}
76
+ * @private
84
77
  */
85
- private _transactionID: string
78
+ private transactionID: string
86
79
  /**
87
- * ${1:Description placeholder}
88
- *
89
- * @private
90
- * @type {(Array<string> | false)}
80
+ * An array of strings representing a blacklist of filters, or false if no blacklist is set.
91
81
  */
92
- private _filterBlacklist: Array<string> | false
82
+ private filterBlacklist: Array<string> | false
93
83
  /**
94
- * ${1:Description placeholder}
95
- *
84
+ * The current log level for the application.
96
85
  * @private
97
86
  * @type {LOG_LEVELS}
98
87
  */
99
88
  private _LOG_LEVEL: LOG_LEVELS
100
89
  /**
101
- * ${1:Description placeholder}
102
- *
90
+ * The origin of the object.
103
91
  * @private
104
- * @type {*}
92
+ * @type {any}
105
93
  */
106
94
  private origin: any
107
95
 
108
96
  /**
109
- * Creates an instance of Logger.
110
- *
111
- * @constructor
112
- * @param {(LoggerConfig | undefined)} _config
113
- * @param {string} transactionID
97
+ * Constructs a Logger object with the given configuration and transaction ID.
98
+ * @param {config} config - The configuration object for the logger. Can be undefined.
99
+ * @param {string} transactionID - The ID of the transaction associated with the logger.
100
+ * @returns None
114
101
  */
115
- constructor(_config: LoggerConfig | undefined, transactionID: string) {
102
+ constructor(config: LoggerConfig | undefined, transactionID: string) {
116
103
  abind(this)
117
104
  //
118
105
  this.origin = PURE_CONSOLE
119
- this._LOG_LEVEL = _config?.logLevel
120
- ? LOG_LEVELS[_config?.logLevel] || LOG_LEVELS.DEBUG
106
+ this._LOG_LEVEL = config?.logLevel
107
+ ? LOG_LEVELS[config?.logLevel] || LOG_LEVELS.DEBUG
121
108
  : LOG_LEVELS.DEBUG
122
- this._config = _config || {}
123
- this._transactionID = transactionID
124
- this._filterBlacklist = this._config.sensitiveFilteringKeywords
125
- ? Array.isArray(this._config.sensitiveFilteringKeywords)
126
- ? this._config.sensitiveFilteringKeywords
109
+ this.config = config || {}
110
+ this.transactionID = transactionID
111
+ this.filterBlacklist = this.config.sensitiveFilteringKeywords
112
+ ? Array.isArray(this.config.sensitiveFilteringKeywords)
113
+ ? this.config.sensitiveFilteringKeywords
127
114
  : blacklist
128
115
  : false
129
116
  //
130
- this._setupBindings()
117
+ this.setupBindings()
131
118
  //
132
119
  this.log('Using logger with level: ' + this._LOG_LEVEL.toString())
133
- this.debug('logger config: ', this._config)
120
+ this.debug('logger config: ', this.config)
134
121
  }
122
+
135
123
  /**
136
- * ${1:Description placeholder}
137
- *
138
- * @public
139
- * @returns {boolean}
124
+ * Returns a boolean value indicating whether the notGlobalLogger function is executed successfully.
125
+ * @returns {boolean} - true if the function is executed successfully, false otherwise.
140
126
  */
141
127
  public notGlobalLogger() {
142
128
  return true
143
129
  }
144
130
 
145
- //Public
146
131
  /**
147
- * ${1:Description placeholder}
148
- *
149
- * @param {...{}\} args
132
+ * Logs the given arguments with the debug log level.
133
+ * @param {...any} args - The arguments to be logged.
134
+ * @returns None
150
135
  */
151
136
  debug(...args) {
152
- this._processLog(LOG_LEVELS.DEBUG, args)
137
+ this.processLog(LOG_LEVELS.DEBUG, args)
153
138
  }
139
+
154
140
  /**
155
- * ${1:Description placeholder}
156
- *
157
- * @param {...{}\} args
141
+ * Logs the given arguments with the INFO log level.
142
+ * @param {...any} args - The arguments to be logged.
143
+ * @returns None
158
144
  */
159
145
  log(...args) {
160
- this._processLog(LOG_LEVELS.INFO, args)
146
+ this.processLog(LOG_LEVELS.INFO, args)
161
147
  }
148
+
162
149
  /**
163
- * ${1:Description placeholder}
164
- *
165
- * @param {...{}\} args
150
+ * Logs an informational message.
151
+ * @param {...any} args - The message(s) to log.
152
+ * @returns None
166
153
  */
167
154
  info(...args) {
168
- this._processLog(LOG_LEVELS.INFO, args)
155
+ this.processLog(LOG_LEVELS.INFO, args)
169
156
  }
157
+
170
158
  /**
171
- * ${1:Description placeholder}
172
- *
173
- * @param {...{}\} args
159
+ * Logs a warning message with the provided arguments.
160
+ * @param {...any} args - The arguments to be logged as a warning message.
161
+ * @returns None
174
162
  */
175
163
  warning(...args) {
176
- this._processLog(LOG_LEVELS.WARN, args)
164
+ this.processLog(LOG_LEVELS.WARN, args)
177
165
  }
166
+
178
167
  /**
179
- * ${1:Description placeholder}
180
- *
181
- * @param {...{}\} args
168
+ * Logs a warning message to the console.
169
+ * @param {...any} args - The arguments to be logged.
170
+ * @returns None
182
171
  */
183
172
  warn(...args) {
184
- this._processLog(LOG_LEVELS.WARN, args)
173
+ this.processLog(LOG_LEVELS.WARN, args)
185
174
  }
175
+
186
176
  /**
187
- * ${1:Description placeholder}
188
- *
189
- * @param {...{}\} args
177
+ * Logs an error message with the given arguments.
178
+ * @param {...any} args - The arguments to log as an error message.
179
+ * @returns None
190
180
  */
191
181
  error(...args) {
192
- this._processLog(LOG_LEVELS.ERROR, args)
182
+ this.processLog(LOG_LEVELS.ERROR, args)
193
183
  }
184
+
194
185
  /**
195
- * ${1:Description placeholder}
196
- *
197
- * @param {*} exception
198
- * @param {...{}\} args
186
+ * Logs an exception with optional additional arguments.
187
+ * @param {any} exception - The exception to log.
188
+ * @param {...any} args - Additional arguments to include in the log.
189
+ * @returns None
199
190
  */
200
191
  exception(exception, ...args) {
201
- this._exception(exception, args)
192
+ this.iexception(exception, args)
202
193
  }
203
194
 
204
- //initialization
205
195
  /**
206
- * ${1:Description placeholder}
207
- *
196
+ * Sets up the console bindings for logging purposes.
208
197
  * @private
198
+ * @returns None
209
199
  */
210
- private _setupBindings(): void {
200
+ private setupBindings(): void {
211
201
  global.console = {
212
- debug: (...args) => this._processLog(LOG_LEVELS.DEBUG, args),
213
- log: (...args) => this._processLog(LOG_LEVELS.INFO, args),
214
- info: (...args) => this._processLog(LOG_LEVELS.INFO, args),
215
- warn: (...args) => this._processLog(LOG_LEVELS.WARN, args),
216
- error: (...args) => this._processLog(LOG_LEVELS.ERROR, args),
202
+ debug: (...args) => this.processLog(LOG_LEVELS.DEBUG, args),
203
+ log: (...args) => this.processLog(LOG_LEVELS.INFO, args),
204
+ info: (...args) => this.processLog(LOG_LEVELS.INFO, args),
205
+ warn: (...args) => this.processLog(LOG_LEVELS.WARN, args),
206
+ error: (...args) => this.processLog(LOG_LEVELS.ERROR, args),
217
207
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
218
208
  // @ts-ignore
219
- warning: (...args) => this._processLog(LOG_LEVELS.WARN, args),
220
- exception: (exception, ...args) => this._exception(exception, args),
209
+ warning: (...args) => this.processLog(LOG_LEVELS.WARN, args),
210
+ exception: (exception, ...args) => this.iexception(exception, args),
221
211
  }
222
212
  }
223
213
 
224
- /* Formatters */
225
214
  /**
226
- * ${1:Description placeholder}
227
- *
228
- * @private
229
- * @param {LOG_LEVELS} level
230
- * @param {Array<string>} msg
231
- * @param {string} caller
232
- * @returns {string}
215
+ * Formats a log message with the specified log level, message, and caller.
216
+ * @param {LOG_LEVELS} level - The log level of the message.
217
+ * @param {Array<string>} msg - An array of strings representing the message.
218
+ * @param {string} caller - The name of the caller function.
219
+ * @returns {string} - The formatted log message.
233
220
  */
234
- private _formattedLog(level: LOG_LEVELS, msg: Array<string>, caller: string): string {
235
- if (Utils.isHybridlessContainer() && this._transactionID) {
221
+ private formattedLog(level: LOG_LEVELS, msg: Array<string>, caller: string): string {
222
+ if (Utils.isHybridlessContainer() && this.transactionID) {
236
223
  return (
237
- `${this._transactionID}` +
238
- ` [${level.toString()}] [${caller}] ${msg.map(this._suppressSensitiveInfo).join(' ')}`
224
+ `${this.transactionID}` +
225
+ ` [${level.toString()}] [${caller}] ${msg.map(this.suppressSensitiveInfo).join(' ')}`
239
226
  )
240
227
  } else {
241
- return `[${level.toString()}] [${caller}] ${msg.map(this._suppressSensitiveInfo).join(' ')}`
228
+ return `[${level.toString()}] [${caller}] ${msg.map(this.suppressSensitiveInfo).join(' ')}`
242
229
  }
243
230
  }
231
+
244
232
  /**
245
- * ${1:Description placeholder}
246
- *
247
- * @private
248
- * @param {number} index
249
- * @returns {string}
233
+ * Returns the name of the caller at the specified index in the call stack.
234
+ * @param {number} index - The index of the caller in the call stack.
235
+ * @returns {string} The name of the caller, including the file name and line number.
250
236
  */
251
- private _callerName(index: number): string {
237
+ private callerName(index: number): string {
252
238
  const safeIndex = Math.min(index, stackTrace.get().length)
253
239
  if (stackTrace.get()[safeIndex]) {
254
240
  let callerName = stackTrace.get()[safeIndex]
@@ -262,15 +248,14 @@ export default class Logger {
262
248
  }
263
249
  return ''
264
250
  }
265
- /* Helpers (core functionality) */
251
+
266
252
  /**
267
- * ${1:Description placeholder}
268
- *
269
- * @private
270
- * @param {LOG_LEVELS} level
271
- * @param {*} args
253
+ * Processes a log message based on the specified log level and arguments.
254
+ * @param {LOG_LEVELS} level - The log level of the message.
255
+ * @param {any[]} args - The arguments to be logged.
256
+ * @returns None
272
257
  */
273
- private _processLog(level: LOG_LEVELS, args: any): void {
258
+ private processLog(level: LOG_LEVELS, args: any): void {
274
259
  if (level < this._LOG_LEVEL) return
275
260
  //get args
276
261
  const msg: Array<string> = []
@@ -281,16 +266,16 @@ export default class Logger {
281
266
  }
282
267
  //push into logs stack
283
268
  // todo: improve error stack
284
- this._pushLog(level, this._formattedLog(level, msg, this._callerName(3)))
269
+ this.pushLog(level, this.formattedLog(level, msg, this.callerName(3)))
285
270
  }
271
+
286
272
  /**
287
- * ${1:Description placeholder}
288
- *
289
- * @private
290
- * @param {Error} exception
291
- * @param {...{}\} args
273
+ * Logs an exception along with additional arguments and the stack trace.
274
+ * @param {Error} exception - The exception object to log.
275
+ * @param {...any} args - Additional arguments to include in the log.
276
+ * @returns None
292
277
  */
293
- private _exception(exception: Error, ...args): void {
278
+ private iexception(exception: Error, ...args): void {
294
279
  //format message
295
280
  const msg: Array<string> = []
296
281
  //push exeception
@@ -299,37 +284,33 @@ export default class Logger {
299
284
  for (const arg of args) if (arg != exception) msg.push(arg)
300
285
  if (exception.stack) msg.push(exception.stack) //push Exeception stack at the end
301
286
  //push into logs stack
302
- this._pushLog(LOG_LEVELS.ERROR, this._formattedLog(LOG_LEVELS.ERROR, msg, this._callerName(3)))
287
+ this.pushLog(LOG_LEVELS.ERROR, this.formattedLog(LOG_LEVELS.ERROR, msg, this.callerName(3)))
303
288
  }
289
+
304
290
  /**
305
- * ${1:Description placeholder}
306
- *
307
- * @private
308
- * @param {LOG_LEVELS} level
309
- * @param {string} fMsg
291
+ * Pushes a log message to the console with the specified log level.
292
+ * @param {LOG_LEVELS} level - The log level of the message.
293
+ * @param {string} fMsg - The formatted log message.
294
+ * @returns None
310
295
  */
311
- private _pushLog(level: LOG_LEVELS, fMsg: string): void {
312
- // push into logs stack
313
- // this._logs.push(fMsg);
296
+ private pushLog(level: LOG_LEVELS, fMsg: string): void {
314
297
  DEFAULT_LOG_FUNCTION.apply(PURE_CONSOLE, [fMsg])
315
298
  }
316
- /* Sensitive information handling */
299
+
317
300
  /**
318
- * ${1:Description placeholder}
319
- *
320
- * @private
321
- * @param {*} value
322
- * @returns {string}
301
+ * Suppresses sensitive information in the given value based on the filter blacklist.
302
+ * @param {any} value - The value to suppress sensitive information from.
303
+ * @returns {string} - The value with sensitive information suppressed.
323
304
  */
324
- private _suppressSensitiveInfo(value: any): string {
305
+ private suppressSensitiveInfo(value: any): string {
325
306
  //realy false
326
- if (!this._filterBlacklist) return value
307
+ if (!this.filterBlacklist) return value
327
308
  if (typeof value == 'string') {
328
309
  //content based replacement
329
- if (this._filterBlacklist) {
330
- this._filterBlacklist.forEach(() => {
331
- const match = this._filterBlacklist
332
- ? this._filterBlacklist.find(f => value.toLowerCase().includes(f.toLowerCase()))
310
+ if (this.filterBlacklist) {
311
+ this.filterBlacklist.forEach(() => {
312
+ const match = this.filterBlacklist
313
+ ? this.filterBlacklist.find(f => value.toLowerCase().includes(f.toLowerCase()))
333
314
  : false
334
315
  if (match) value = '**SUPPRESSED_SENSITIVE_DATA**'
335
316
  })