@nestjs/common 9.3.12 → 9.4.1

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  <p align="center">
2
- <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
2
+ <a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
3
3
  </p>
4
4
 
5
5
  [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6
6
  [circleci-url]: https://circleci.com/gh/nestjs/nest
7
7
 
8
- <p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
8
+ <p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9
9
  <p align="center">
10
10
  <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11
11
  <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
132
132
  <td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
133
133
  <td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
134
134
  <td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
135
- <td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
135
+ <td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
136
136
  <td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
137
137
  <td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
138
138
  <td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
@@ -1,4 +1,12 @@
1
+ /**
2
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
3
+ * @publicApi
4
+ */
1
5
  export declare const CACHE_MANAGER = "CACHE_MANAGER";
2
6
  export declare const CACHE_KEY_METADATA = "cache_module:cache_key";
3
7
  export declare const CACHE_TTL_METADATA = "cache_module:cache_ttl";
8
+ /**
9
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
10
+ * @publicApi
11
+ */
4
12
  export declare const CACHE_MODULE_OPTIONS: string | symbol;
@@ -2,7 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CACHE_MODULE_OPTIONS = exports.CACHE_TTL_METADATA = exports.CACHE_KEY_METADATA = exports.CACHE_MANAGER = void 0;
4
4
  const cache_module_definition_1 = require("./cache.module-definition");
5
+ /**
6
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
7
+ * @publicApi
8
+ */
5
9
  exports.CACHE_MANAGER = 'CACHE_MANAGER';
6
10
  exports.CACHE_KEY_METADATA = 'cache_module:cache_key';
7
11
  exports.CACHE_TTL_METADATA = 'cache_module:cache_ttl';
12
+ /**
13
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
14
+ * @publicApi
15
+ */
8
16
  exports.CACHE_MODULE_OPTIONS = cache_module_definition_1.MODULE_OPTIONS_TOKEN;
@@ -1,2 +1,2 @@
1
1
  import { CacheModuleOptions } from './interfaces/cache-module.interface';
2
- export declare const ConfigurableModuleClass: import("../module-utils").ConfigurableModuleCls<CacheModuleOptions<Record<string, any>>, "register", "createCacheOptions", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
2
+ export declare const ConfigurableModuleClass: import("../module-utils").ConfigurableModuleCls<CacheModuleOptions, "register", "createCacheOptions", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
@@ -5,7 +5,7 @@ import { CacheModuleAsyncOptions, CacheModuleOptions } from './interfaces/cache-
5
5
  * Module that provides Nest cache-manager.
6
6
  *
7
7
  * @see [Caching](https://docs.nestjs.com/techniques/caching)
8
- *
8
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
9
9
  * @publicApi
10
10
  */
11
11
  export declare class CacheModule extends ConfigurableModuleClass {
@@ -10,7 +10,7 @@ const cache_providers_1 = require("./cache.providers");
10
10
  * Module that provides Nest cache-manager.
11
11
  *
12
12
  * @see [Caching](https://docs.nestjs.com/techniques/caching)
13
- *
13
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
14
14
  * @publicApi
15
15
  */
16
16
  let CacheModule = class CacheModule extends cache_module_definition_1.ConfigurableModuleClass {
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * @see [Caching](https://docs.nestjs.com/techniques/caching)
11
11
  *
12
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
12
13
  * @publicApi
13
14
  */
14
15
  export declare const CacheKey: (key: string) => import("../../decorators").CustomDecorator<string>;
@@ -14,6 +14,7 @@ const cache_constants_1 = require("../cache.constants");
14
14
  *
15
15
  * @see [Caching](https://docs.nestjs.com/techniques/caching)
16
16
  *
17
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
17
18
  * @publicApi
18
19
  */
19
20
  const CacheKey = (key) => (0, decorators_1.SetMetadata)(cache_constants_1.CACHE_KEY_METADATA, key);
@@ -8,6 +8,7 @@ import { ExecutionContext } from '../../interfaces/features/execution-context.in
8
8
  *
9
9
  * @see [Caching](https://docs.nestjs.com/techniques/caching)
10
10
  *
11
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
11
12
  * @publicApi
12
13
  */
13
14
  type CacheTTLFactory = (ctx: ExecutionContext) => Promise<number> | number;
@@ -1,11 +1,13 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { CallHandler, ExecutionContext, HttpServer, NestInterceptor } from '../../interfaces';
3
+ /** @deprecated Import from the "@nestjs/core" instead. */
3
4
  export interface HttpAdapterHost<T extends HttpServer = any> {
4
5
  httpAdapter: T;
5
6
  }
6
7
  /**
7
8
  * @see [Caching](https://docs.nestjs.com/techniques/caching)
8
9
  *
10
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
9
11
  * @publicApi
10
12
  */
11
13
  export declare class CacheInterceptor implements NestInterceptor {
@@ -10,11 +10,14 @@ const logger_service_1 = require("../../services/logger.service");
10
10
  const load_package_util_1 = require("../../utils/load-package.util");
11
11
  const shared_utils_1 = require("../../utils/shared.utils");
12
12
  const cache_constants_1 = require("../cache.constants");
13
+ /** @deprecated */
13
14
  const HTTP_ADAPTER_HOST = 'HttpAdapterHost';
15
+ /** @deprecated */
14
16
  const REFLECTOR = 'Reflector';
15
17
  /**
16
18
  * @see [Caching](https://docs.nestjs.com/techniques/caching)
17
19
  *
20
+ * @deprecated `CacheModule` (from the `@nestjs/common` package) is deprecated and will be removed in the next major release. Please, use the `@nestjs/cache-manager` package instead
18
21
  * @publicApi
19
22
  */
20
23
  let CacheInterceptor = class CacheInterceptor {
@@ -26,6 +29,7 @@ let CacheInterceptor = class CacheInterceptor {
26
29
  // because the set method signature changed in v5
27
30
  const cacheManagerPackage = (0, load_package_util_1.loadPackage)('cache-manager', 'CacheModule', () => require('cache-manager'));
28
31
  this.cacheManagerIsv5OrGreater = 'memoryStore' in cacheManagerPackage;
32
+ logger_service_1.Logger.warn('DEPRECATED! "CacheModule" (from the "@nestjs/common" package) is deprecated and will be removed in the next major release. Please, use the "@nestjs/cache-manager" package instead.');
29
33
  }
30
34
  async intercept(context, next) {
31
35
  var _a;
@@ -69,7 +69,8 @@ export interface ValidatorOptions {
69
69
  */
70
70
  forbidUnknownValues?: boolean;
71
71
  /**
72
- * When set to true, validation of the given property will stop after encountering the first error. Defaults to false.
72
+ * When set to true, validation of the given property will stop after encountering the first error.
73
+ * This is enabled by default.
73
74
  */
74
75
  stopAtFirstError?: boolean;
75
76
  }
@@ -0,0 +1,6 @@
1
+ export type HttpExceptionBodyMessage = string | string[];
2
+ export interface HttpExceptionBody {
3
+ message: HttpExceptionBodyMessage;
4
+ error?: string;
5
+ statusCode: number;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/common",
3
- "version": "9.3.12",
3
+ "version": "9.4.1",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@common)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "homepage": "https://nestjs.com",
@@ -10,7 +10,8 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/nestjs/nest"
13
+ "url": "https://github.com/nestjs/nest.git",
14
+ "directory": "packages/common"
14
15
  },
15
16
  "publishConfig": {
16
17
  "access": "public"
@@ -19,7 +20,7 @@
19
20
  "dependencies": {
20
21
  "iterare": "1.2.1",
21
22
  "tslib": "2.5.0",
22
- "uid": "2.0.1"
23
+ "uid": "2.0.2"
23
24
  },
24
25
  "peerDependencies": {
25
26
  "cache-manager": "<=5",
@@ -0,0 +1,4 @@
1
+ export interface IFile {
2
+ mimetype: string;
3
+ size: number;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './file.interface';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./file.interface"), exports);
@@ -1,6 +1,7 @@
1
1
  import { FileValidator } from './file-validator.interface';
2
2
  export type MaxFileSizeValidatorOptions = {
3
3
  maxSize: number;
4
+ message?: string | ((maxSize: number) => string);
4
5
  };
5
6
  /**
6
7
  * Defines the built-in MaxSize File Validator
@@ -11,6 +11,12 @@ const file_validator_interface_1 = require("./file-validator.interface");
11
11
  */
12
12
  class MaxFileSizeValidator extends file_validator_interface_1.FileValidator {
13
13
  buildErrorMessage() {
14
+ if ('message' in this.validationOptions) {
15
+ if (typeof this.validationOptions.message === 'function') {
16
+ return this.validationOptions.message(this.validationOptions.maxSize);
17
+ }
18
+ return this.validationOptions.message;
19
+ }
14
20
  return `Validation failed (expected size is less than ${this.validationOptions.maxSize})`;
15
21
  }
16
22
  isValid(file) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ParseFloatPipe = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const index_1 = require("../index");
6
+ const core_1 = require("../decorators/core");
6
7
  const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
7
8
  /**
8
9
  * Defines the built-in ParseFloat Pipe
@@ -43,8 +44,8 @@ let ParseFloatPipe = class ParseFloatPipe {
43
44
  }
44
45
  };
45
46
  ParseFloatPipe = tslib_1.__decorate([
46
- (0, index_1.Injectable)(),
47
- tslib_1.__param(0, (0, index_1.Optional)()),
47
+ (0, core_1.Injectable)(),
48
+ tslib_1.__param(0, (0, core_1.Optional)()),
48
49
  tslib_1.__metadata("design:paramtypes", [Object])
49
50
  ], ParseFloatPipe);
50
51
  exports.ParseFloatPipe = ParseFloatPipe;
@@ -27,6 +27,7 @@ export declare class ConsoleLogger implements LoggerService {
27
27
  * Write an 'error' level log, if the configured level allows for it.
28
28
  * Prints to `stderr` with newline.
29
29
  */
30
+ error(message: any, stackOrContext?: string): void;
30
31
  error(message: any, stack?: string, context?: string): void;
31
32
  error(message: any, ...optionalParams: [...any, string?, string?]): void;
32
33
  /**
@@ -70,9 +71,10 @@ export declare class ConsoleLogger implements LoggerService {
70
71
  protected stringifyMessage(message: unknown, logLevel: LogLevel): any;
71
72
  protected colorize(message: string, logLevel: LogLevel): string;
72
73
  protected printStackTrace(stack: string): void;
73
- private updateAndGetTimestampDiff;
74
+ protected updateAndGetTimestampDiff(): string;
74
75
  protected formatTimestampDiff(timestampDiff: number): string;
75
76
  private getContextAndMessagesToPrint;
76
77
  private getContextAndStackAndMessagesToPrint;
78
+ private isStackFormat;
77
79
  private getColorByLogLevel;
78
80
  }
@@ -179,6 +179,18 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
179
179
  };
180
180
  }
181
181
  getContextAndStackAndMessagesToPrint(args) {
182
+ if (args.length === 2) {
183
+ return this.isStackFormat(args[1])
184
+ ? {
185
+ messages: [args[0]],
186
+ stack: args[1],
187
+ context: this.context,
188
+ }
189
+ : {
190
+ messages: [args[0]],
191
+ context: args[1],
192
+ };
193
+ }
182
194
  const { messages, context } = this.getContextAndMessagesToPrint(args);
183
195
  if ((messages === null || messages === void 0 ? void 0 : messages.length) <= 1) {
184
196
  return { messages, context };
@@ -195,6 +207,12 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
195
207
  context,
196
208
  };
197
209
  }
210
+ isStackFormat(stack) {
211
+ if (!(0, shared_utils_1.isString)(stack) && !(0, shared_utils_1.isUndefined)(stack)) {
212
+ return false;
213
+ }
214
+ return /^(.)+\n\s+at .+:\d+:\d+$/.test(stack);
215
+ }
198
216
  getColorByLogLevel(level) {
199
217
  switch (level) {
200
218
  case 'debug':
@@ -90,6 +90,7 @@ export declare class Logger implements LoggerService {
90
90
  /**
91
91
  * Write an 'error' level log.
92
92
  */
93
+ static error(message: any, stackOrContext?: string): void;
93
94
  static error(message: any, context?: string): void;
94
95
  static error(message: any, stack?: string, context?: string): void;
95
96
  static error(message: any, ...optionalParams: [...any, string?, string?]): void;
@@ -120,12 +121,12 @@ export declare class Logger implements LoggerService {
120
121
  static flush(): void;
121
122
  /**
122
123
  * Attach buffer.
123
- * Turns on initialisation logs buffering.
124
+ * Turns on initialization logs buffering.
124
125
  */
125
126
  static attachBuffer(): void;
126
127
  /**
127
128
  * Detach buffer.
128
- * Turns off initialisation logs buffering.
129
+ * Turns off initialization logs buffering.
129
130
  */
130
131
  static detachBuffer(): void;
131
132
  static getTimestamp(): string;
@@ -101,14 +101,14 @@ let Logger = Logger_1 = class Logger {
101
101
  }
102
102
  /**
103
103
  * Attach buffer.
104
- * Turns on initialisation logs buffering.
104
+ * Turns on initialization logs buffering.
105
105
  */
106
106
  static attachBuffer() {
107
107
  this.isBufferAttached = true;
108
108
  }
109
109
  /**
110
110
  * Detach buffer.
111
- * Turns off initialisation logs buffering.
111
+ * Turns off initialization logs buffering.
112
112
  */
113
113
  static detachBuffer() {
114
114
  this.isBufferAttached = false;
@@ -0,0 +1,2 @@
1
+ import { ExceptionFilterMetadata } from '../interfaces/exceptions';
2
+ export declare const selectExceptionFilterMetadata: <T = any>(filters: ExceptionFilterMetadata[], exception: T) => ExceptionFilterMetadata | undefined;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectExceptionFilterMetadata = void 0;
4
+ const selectExceptionFilterMetadata = (filters, exception) => filters.find(({ exceptionMetatypes }) => !exceptionMetatypes.length ||
5
+ exceptionMetatypes.some(ExceptionMetaType => exception instanceof ExceptionMetaType));
6
+ exports.selectExceptionFilterMetadata = selectExceptionFilterMetadata;