@ti-engine/core 1.3.12 → 1.3.13

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This document will contain the list of changes made to the framework. The format is based on the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
4
4
 
5
+ ## Version 1.3.13
6
+
7
+ * feat(exceptions): add new exception code `E_GEN_UNALLOWED_OVERRIDE` (1009) for detecting attempts to override protected or private methods/properties
8
+ * feat(auditing): enhance console data formatting with recursive, depth-limited formatting (max depth: 5), circular reference detection and handling, improved readability for nested objects and multi-line strings, and proper indentation and prefixing for structured output
9
+ * fix(start instance): modified `start-instance.js` to initialize serviceConfig as undefined instead of an empty object when `TI_INSTANCE_CONFIG` environment variable is not provided
10
+ * build(npm): update npm dependencies to their latest versions
11
+
5
12
  ## Version 1.3.12
6
13
 
7
14
  * feat(exceptions): add new exception code `E_COM_SERVICE_EXEC_FAILED`
@@ -31,6 +31,9 @@
31
31
  "1008": {
32
32
  "en": "The invoked framework component is not initialized."
33
33
  },
34
+ "1009": {
35
+ "en": "Attempt to override a protected or private method or property detected."
36
+ },
34
37
  "2000": {
35
38
  "en": "Invalid authorization token provided."
36
39
  },
@@ -124,7 +124,7 @@ try {
124
124
  const serviceConstructor = require( path.join( process.cwd(), process.env.TI_INSTANCE_CLASS ) );
125
125
  const serviceConfigPath = process.env.TI_INSTANCE_CONFIG;
126
126
  /** @type ServiceConfiguration */
127
- let serviceConfig = {};
127
+ let serviceConfig;
128
128
  if ( serviceConfigPath ) {
129
129
  serviceConfig = require( path.join( process.cwd(), process.env.TI_INSTANCE_CONFIG ) );
130
130
  }
@@ -6,6 +6,7 @@
6
6
  * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
7
7
  */
8
8
 
9
+ const { EOL } = require( "node:os" )
9
10
  const _ = require( "lodash" );
10
11
  const tools = require( "#tools" );
11
12
  const logger = require( "#logger" );
@@ -132,7 +133,7 @@ class Auditing {
132
133
  } else {
133
134
  console.log( Auditing.#formatConsoleMessage( logEntry ) );
134
135
  if ( !_.isEmpty( logEntry.data ) ) {
135
- console.log( ` » ${ Auditing.#formatConsoleData( logEntry ) }` );
136
+ console.log( Auditing.#formatConsoleData( logEntry.data, " " ) );
136
137
  }
137
138
  }
138
139
  }
@@ -154,12 +155,53 @@ class Auditing {
154
155
  * Used to format a log entry data payload for the Node console.
155
156
  *
156
157
  * @method
157
- * @param {TiLogEntry} logEntry
158
+ * @param {*} data
159
+ * @param {string} [prefix=""]
160
+ * @param {number} [currentDepth=0]
161
+ * @param {number} [maxDepth=5]
162
+ * @param {Set} [visited=new Set()]
158
163
  * @returns {string}
159
164
  * @private
160
165
  */
161
- static #formatConsoleData( logEntry ) {
162
- return tools.stringifyJSON( logEntry.data );
166
+ static #formatConsoleData( data, prefix = "", currentDepth = 0, maxDepth = 5, visited = new Set() ) {
167
+ if ( data === null || data === undefined || !_.isObjectLike( data ) ) {
168
+ // Handle null, undefined, and primitive values:
169
+ return prefix + "» " + String( data );
170
+ } else if ( currentDepth >= maxDepth ) {
171
+ // Check max depth:
172
+ return prefix + "! [max data depth reached]";
173
+ } else if ( visited.has( data ) ) {
174
+ // Check for circular references:
175
+ return prefix + "! [circular reference detected]";
176
+ } else {
177
+ let formattedData = "";
178
+ visited.add( data );
179
+
180
+ _.forOwn( data, ( value, key ) => {
181
+ let stackLines = ( _.isString( value ) ) ? value.split( "\n" ) : [ value ];
182
+ if ( stackLines.length > 1 ) {
183
+ _.forEach( stackLines, ( line, idx ) => {
184
+ if ( idx === 0 ) {
185
+ formattedData += prefix + `» ${ key }: ${ _.trim( line ) }` + EOL;
186
+ } else {
187
+ formattedData += prefix + `- ${ _.trim( line ) }` + EOL;
188
+ }
189
+ } );
190
+ } else {
191
+ if ( _.isObjectLike( value ) ) {
192
+ formattedData += prefix + `» ${ key }:` + EOL + Auditing.#formatConsoleData( value, " " + prefix, currentDepth + 1, maxDepth, visited ) + EOL;
193
+ } else {
194
+ formattedData += prefix + `» ${ key }: ${ value }` + EOL;
195
+ }
196
+ }
197
+ } );
198
+
199
+ if ( formattedData.endsWith( EOL ) ) {
200
+ formattedData = formattedData.slice( 0, -EOL.length );
201
+ }
202
+
203
+ return formattedData;
204
+ }
163
205
  }
164
206
  }
165
207
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ti-engine/core",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.",
5
5
  "keywords": [
6
6
  "microservices",
@@ -57,7 +57,7 @@
57
57
  "#tools": "./utils/tools.js"
58
58
  },
59
59
  "dependencies": {
60
- "@dotenvx/dotenvx": "^1.51.0",
60
+ "@dotenvx/dotenvx": "^1.51.1",
61
61
  "blake2": "^5.0.0",
62
62
  "ioredis": "^5.8.2",
63
63
  "lodash": "^4.17.21",
@@ -28,6 +28,7 @@ const exceptionCodeEnum = tools.enum( {
28
28
  E_GEN_FEATURE_UNSUPPORTED: [ 1006, "feature unsupported", "The requested feature is not supported by current configuration or version." ],
29
29
  E_GEN_INVALID_ARGUMENT_TYPE: [ 1007, "invalid argument type", "The provided argument is not of the expected type." ],
30
30
  E_GEN_NOT_INITIALIZED: [ 1008, "not initialized", "The invoked framework component is not initialized." ],
31
+ E_GEN_UNALLOWED_OVERRIDE: [ 1009, "unallowed override", "Attempt to override a protected or private method or property detected." ],
31
32
  /** Security & Administration exceptions - codes under 2xxx */
32
33
  E_SEC_INVALID_AUTH_TOKEN: [ 2000, "invalid auth token", "Invalid authorization token provided." ],
33
34
  E_SEC_INVALID_EXPIRED_SESSION: [ 2001, "invalid or expired session", "Invalid or expired session encountered." ],