@nestjs/common 7.6.4 → 7.6.8

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2020 Kamil Mysliwiec <https://kamilmysliwiec.com>
3
+ Copyright (c) 2017-2021 Kamil Mysliwiec <https://kamilmysliwiec.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/Readme.md CHANGED
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
56
56
 
57
57
  #### Principal Sponsors
58
58
  <table style="text-align:center;"><tr><td>
59
- <a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
60
- <a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
59
+ <a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
60
+ <td>
61
+ <a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
61
62
  </tr></table>
62
63
 
64
+ #### Gold Sponsors
65
+
66
+ <table style="text-align:center;"><tr><td>
67
+ <a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
68
+
63
69
  #### Silver Sponsors
64
70
 
65
71
  <table style="text-align:center;"><tr><td>
66
72
  <a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
67
73
  <a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
68
- <a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
69
74
  <a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
70
75
  <a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
71
76
 
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
90
95
  <td align="center" valign="middle">
91
96
  <a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
92
97
  <td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
98
+ <td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
99
+ <td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
100
+ <td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
101
+ <td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
102
+ <td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
93
103
  </tr></table>
94
104
 
95
105
  ## Backers
@@ -50,4 +50,9 @@ export interface ClassTransformOptions {
50
50
  * and exposing all class properties (with undefined, if nothing else is given)
51
51
  */
52
52
  excludeExtraneousValues?: boolean;
53
+ /**
54
+ * If set to true then class transformer will take default values for unprovided fields.
55
+ * This is useful when you convert a plain object to a class and have an optional field with a default value.
56
+ */
57
+ exposeDefaultValues?: boolean;
53
58
  }
@@ -48,3 +48,9 @@ export interface CorsOptions {
48
48
  */
49
49
  optionsSuccessStatus?: number;
50
50
  }
51
+ export interface CorsOptionsCallback {
52
+ (error: Error, options: CorsOptions): void;
53
+ }
54
+ export interface CorsOptionsDelegate<T> {
55
+ (req: T, cb: CorsOptionsCallback): void;
56
+ }
@@ -2,29 +2,41 @@
2
2
  * Validation error description.
3
3
  * @see https://github.com/typestack/class-validator
4
4
  *
5
+ * class-validator@0.13.0
6
+ *
5
7
  * @publicApi
6
8
  */
7
9
  export interface ValidationError {
8
10
  /**
9
11
  * Object that was validated.
12
+ *
13
+ * OPTIONAL - configurable via the ValidatorOptions.validationError.target option
10
14
  */
11
- target: Record<string, any>;
15
+ target?: Record<string, any>;
12
16
  /**
13
17
  * Object's property that hasn't passed validation.
14
18
  */
15
19
  property: string;
16
20
  /**
17
- * Value that hasn't passed validation.
21
+ * Value that haven't pass a validation.
22
+ *
23
+ * OPTIONAL - configurable via the ValidatorOptions.validationError.value option
18
24
  */
19
- value: any;
25
+ value?: any;
20
26
  /**
21
27
  * Constraints that failed validation with error messages.
22
28
  */
23
- constraints: {
29
+ constraints?: {
24
30
  [type: string]: string;
25
31
  };
26
32
  /**
27
33
  * Contains all nested validation errors of the property.
28
34
  */
29
- children: ValidationError[];
35
+ children?: ValidationError[];
36
+ /**
37
+ * A transient set of data passed through to the validation result for response mapping
38
+ */
39
+ contexts?: {
40
+ [type: string]: any;
41
+ };
30
42
  }
@@ -2,11 +2,15 @@
2
2
  * Options passed to validator during validation.
3
3
  * @see https://github.com/typestack/class-validator
4
4
  *
5
- * class-validator@0.10.1
5
+ * class-validator@0.13.0
6
6
  *
7
7
  * @publicApi
8
8
  */
9
9
  export interface ValidatorOptions {
10
+ /**
11
+ * If set to true then class-validator will print extra warning messages to the console when something is not right.
12
+ */
13
+ enableDebugMessages?: boolean;
10
14
  /**
11
15
  * If set to true then validator will skip validation of all properties that are undefined in the validating object.
12
16
  */
@@ -33,6 +37,15 @@ export interface ValidatorOptions {
33
37
  * Groups to be used during validation of the object.
34
38
  */
35
39
  groups?: string[];
40
+ /**
41
+ * Set default for `always` option of decorators. Default can be overridden in decorator options.
42
+ */
43
+ always?: boolean;
44
+ /**
45
+ * If [groups]{@link ValidatorOptions#groups} is not given or is empty,
46
+ * ignore decorators with at least one group.
47
+ */
48
+ strictGroups?: boolean;
36
49
  /**
37
50
  * If set to true, the validation will not use default messages.
38
51
  * Error message always will be undefined if its not explicitly set.
@@ -55,4 +68,8 @@ export interface ValidatorOptions {
55
68
  * Settings true will cause fail validation of unknown objects.
56
69
  */
57
70
  forbidUnknownValues?: boolean;
71
+ /**
72
+ * When set to true, validation of the given property will stop after encountering the first error. Defaults to false.
73
+ */
74
+ stopAtFirstError?: boolean;
58
75
  }
@@ -1,5 +1,5 @@
1
1
  import { RequestMethod } from '../../enums';
2
- import { CorsOptions } from '../../interfaces/external/cors-options.interface';
2
+ import { CorsOptions, CorsOptionsDelegate } from '../../interfaces/external/cors-options.interface';
3
3
  import { NestApplicationOptions } from '../../interfaces/nest-application-options.interface';
4
4
  export declare type ErrorHandler<TRequest = any, TResponse = any> = (error: any, req: TRequest, res: TResponse, next?: Function) => any;
5
5
  export declare type RequestHandler<TRequest = any, TResponse = any> = (req: TRequest, res: TResponse, next?: Function) => any;
@@ -38,7 +38,7 @@ export interface HttpServer<TRequest = any, TResponse = any> {
38
38
  getRequestUrl?(request: TResponse): string;
39
39
  getInstance(): any;
40
40
  registerParserMiddleware(): any;
41
- enableCors(options: CorsOptions): any;
41
+ enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>): any;
42
42
  getHttpServer(): any;
43
43
  initHttpServer(options: NestApplicationOptions): void;
44
44
  close(): any;
@@ -1,6 +1,7 @@
1
1
  import { ShutdownSignal } from '../enums/shutdown-signal.enum';
2
2
  import { LoggerService, LogLevel } from '../services/logger.service';
3
3
  import { Abstract } from './abstract.interface';
4
+ import { DynamicModule } from './modules';
4
5
  import { Type } from './type.interface';
5
6
  /**
6
7
  * Interface defining NestApplicationContext.
@@ -12,7 +13,7 @@ export interface INestApplicationContext {
12
13
  * Allows navigating through the modules tree, for example, to pull out a specific instance from the selected module.
13
14
  * @returns {INestApplicationContext}
14
15
  */
15
- select<T>(module: Type<T>): INestApplicationContext;
16
+ select<T>(module: Type<T> | DynamicModule): INestApplicationContext;
16
17
  /**
17
18
  * Retrieves an instance of either injectable or controller, otherwise, throws exception.
18
19
  * @returns {TResult}
@@ -1,4 +1,4 @@
1
- import { CorsOptions } from './external/cors-options.interface';
1
+ import { CorsOptions, CorsOptionsDelegate } from './external/cors-options.interface';
2
2
  import { HttpsOptions } from './external/https-options.interface';
3
3
  import { NestApplicationContextOptions } from './nest-application-context-options.interface';
4
4
  /**
@@ -8,7 +8,7 @@ export interface NestApplicationOptions extends NestApplicationContextOptions {
8
8
  /**
9
9
  * CORS options from [CORS package](https://github.com/expressjs/cors#configuration-options)
10
10
  */
11
- cors?: boolean | CorsOptions;
11
+ cors?: boolean | CorsOptions | CorsOptionsDelegate<any>;
12
12
  /**
13
13
  * Whether to use underlying platform body parser.
14
14
  */
@@ -1,4 +1,4 @@
1
- import { CorsOptions } from './external/cors-options.interface';
1
+ import { CorsOptions, CorsOptionsDelegate } from './external/cors-options.interface';
2
2
  import { CanActivate } from './features/can-activate.interface';
3
3
  import { NestInterceptor } from './features/nest-interceptor.interface';
4
4
  import { HttpServer } from './http/http-server.interface';
@@ -23,7 +23,7 @@ export interface INestApplication extends INestApplicationContext {
23
23
  *
24
24
  * @returns {void}
25
25
  */
26
- enableCors(options?: CorsOptions): void;
26
+ enableCors(options?: CorsOptions | CorsOptionsDelegate<any>): void;
27
27
  /**
28
28
  * Starts the application.
29
29
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/common",
3
- "version": "7.6.4",
3
+ "version": "7.6.8",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@common)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "homepage": "https://nestjs.com",
@@ -17,9 +17,9 @@
17
17
  },
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "axios": "0.21.0",
20
+ "axios": "0.21.1",
21
21
  "iterare": "1.2.1",
22
- "tslib": "2.0.3",
22
+ "tslib": "2.1.0",
23
23
  "uuid": "8.3.2"
24
24
  },
25
25
  "peerDependencies": {
@@ -89,15 +89,18 @@ let Logger = Logger_1 = class Logger {
89
89
  return Logger_1.logLevels.includes(level);
90
90
  }
91
91
  static printMessage(message, color, context = '', isTimeDiffEnabled, writeStreamType) {
92
- var _a;
93
- const output = shared_utils_1.isObject(message)
92
+ var _a, _b;
93
+ const output = shared_utils_1.isPlainObject(message)
94
94
  ? `${color('Object:')}\n${JSON.stringify(message, null, 2)}\n`
95
95
  : color(message);
96
96
  const pidMessage = color(`[Nest] ${process.pid} - `);
97
97
  const contextMessage = context ? cli_colors_util_1.yellow(`[${context}] `) : '';
98
98
  const timestampDiff = this.updateAndGetTimestampDiff(isTimeDiffEnabled);
99
99
  const instance = (_a = this.instance) !== null && _a !== void 0 ? _a : Logger_1;
100
- const computedMessage = `${pidMessage}${instance.getTimestamp()} ${contextMessage}${output}${timestampDiff}\n`;
100
+ const timestamp = instance.getTimestamp
101
+ ? instance.getTimestamp()
102
+ : (_b = Logger_1.getTimestamp) === null || _b === void 0 ? void 0 : _b.call(Logger_1);
103
+ const computedMessage = `${pidMessage}${timestamp} ${contextMessage}${output}${timestampDiff}\n`;
101
104
  process[writeStreamType !== null && writeStreamType !== void 0 ? writeStreamType : 'stdout'].write(computedMessage);
102
105
  }
103
106
  static updateAndGetTimestampDiff(isTimeDiffEnabled) {