@nestjs/common 11.1.3 → 11.1.5

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.
@@ -5,7 +5,9 @@ exports.flatten = flatten;
5
5
  const constants_1 = require("../../constants");
6
6
  function flatten(arr) {
7
7
  const flat = [].concat(...arr);
8
- return flat.some(Array.isArray) ? flatten(flat) : flat;
8
+ return flat.some(Array.isArray)
9
+ ? flatten(flat)
10
+ : flat;
9
11
  }
10
12
  /**
11
13
  * Decorator that sets required dependencies (required with a vanilla JavaScript objects)
@@ -46,4 +46,17 @@ export declare class NestApplicationContextOptions {
46
46
  * @default 'reference'
47
47
  */
48
48
  moduleIdGeneratorAlgorithm?: 'deep-hash' | 'reference';
49
+ /**
50
+ * Instrument the application context.
51
+ * This option allows you to add custom instrumentation to the application context.
52
+ */
53
+ instrument?: {
54
+ /**
55
+ * Function that decorates each instance created by the application context.
56
+ * This function can be used to add custom properties or methods to the instance.
57
+ * @param instance The instance to decorate.
58
+ * @returns The decorated instance.
59
+ */
60
+ instanceDecorator: (instance: unknown) => unknown;
61
+ };
49
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/common",
3
- "version": "11.1.3",
3
+ "version": "11.1.5",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@common)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "homepage": "https://nestjs.com",
@@ -59,7 +59,7 @@ export interface ConsoleLoggerOptions {
59
59
  */
60
60
  sorted?: boolean | ((a: string, b: string) => number);
61
61
  /**
62
- * Specifies the number of times to recurse while formatting object. T
62
+ * Specifies the number of times to recurse while formatting object.
63
63
  * This is useful for inspecting large objects. To recurse up to the maximum call stack size pass Infinity or null.
64
64
  * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
65
65
  * @default 5
@@ -166,6 +166,19 @@ export declare class ConsoleLogger implements LoggerService {
166
166
  writeStreamType?: 'stdout' | 'stderr';
167
167
  errorStack?: unknown;
168
168
  }): void;
169
+ protected getJsonLogObject(message: unknown, options: {
170
+ context: string;
171
+ logLevel: LogLevel;
172
+ writeStreamType?: 'stdout' | 'stderr';
173
+ errorStack?: unknown;
174
+ }): {
175
+ level: LogLevel;
176
+ pid: number;
177
+ timestamp: number;
178
+ message: unknown;
179
+ context?: string;
180
+ stack?: unknown;
181
+ };
169
182
  protected formatPid(pid: number): string;
170
183
  protected formatContext(context: string): string;
171
184
  protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
@@ -155,6 +155,13 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
155
155
  });
156
156
  }
157
157
  printAsJson(message, options) {
158
+ const logObject = this.getJsonLogObject(message, options);
159
+ const formattedMessage = !this.options.colors && this.inspectOptions.compact === true
160
+ ? JSON.stringify(logObject, this.stringifyReplacer)
161
+ : (0, util_1.inspect)(logObject, this.inspectOptions);
162
+ process[options.writeStreamType ?? 'stdout'].write(`${formattedMessage}\n`);
163
+ }
164
+ getJsonLogObject(message, options) {
158
165
  const logObject = {
159
166
  level: options.logLevel,
160
167
  pid: process.pid,
@@ -167,10 +174,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
167
174
  if (options.errorStack) {
168
175
  logObject.stack = options.errorStack;
169
176
  }
170
- const formattedMessage = !this.options.colors && this.inspectOptions.compact === true
171
- ? JSON.stringify(logObject, this.stringifyReplacer)
172
- : (0, util_1.inspect)(logObject, this.inspectOptions);
173
- process[options.writeStreamType ?? 'stdout'].write(`${formattedMessage}\n`);
177
+ return logObject;
174
178
  }
175
179
  formatPid(pid) {
176
180
  return `[${this.options.prefix}] ${pid} - `;