@nestjs/core 8.2.3 → 8.3.0

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 (88) hide show
  1. package/LICENSE +1 -1
  2. package/Readme.md +8 -2
  3. package/adapters/index.js +1 -1
  4. package/application-config.js +4 -0
  5. package/discovery/discovery-module.js +2 -2
  6. package/discovery/discovery-service.js +5 -5
  7. package/discovery/index.js +2 -2
  8. package/errors/exceptions/invalid-class-module.exception.d.ts +4 -0
  9. package/errors/exceptions/invalid-class-module.exception.js +11 -0
  10. package/errors/exceptions/invalid-class-scope.exception.js +2 -2
  11. package/errors/exceptions/invalid-class.exception.js +1 -1
  12. package/errors/exceptions/invalid-middleware.exception.js +1 -1
  13. package/errors/exceptions/invalid-module.exception.js +1 -1
  14. package/errors/exceptions/undefined-dependency.exception.js +1 -1
  15. package/errors/exceptions/undefined-forwardref.exception.js +1 -1
  16. package/errors/exceptions/undefined-module.exception.js +1 -1
  17. package/errors/exceptions/unknown-dependencies.exception.js +1 -1
  18. package/errors/exceptions/unknown-export.exception.js +1 -1
  19. package/errors/messages.d.ts +2 -1
  20. package/errors/messages.js +22 -9
  21. package/exceptions/base-exception-filter-context.js +3 -3
  22. package/exceptions/base-exception-filter.js +6 -6
  23. package/exceptions/exceptions-handler.js +1 -1
  24. package/exceptions/external-exception-filter-context.js +2 -2
  25. package/exceptions/external-exceptions-handler.js +1 -1
  26. package/exceptions/index.js +1 -1
  27. package/guards/guards-consumer.js +2 -2
  28. package/guards/guards-context-creator.js +4 -4
  29. package/helpers/context-utils.js +8 -4
  30. package/helpers/external-context-creator.js +3 -3
  31. package/helpers/index.js +2 -2
  32. package/helpers/interfaces/index.js +2 -2
  33. package/helpers/messages.js +10 -8
  34. package/hooks/before-app-shutdown.hook.js +5 -5
  35. package/hooks/index.js +5 -5
  36. package/hooks/on-app-bootstrap.hook.js +5 -5
  37. package/hooks/on-app-shutdown.hook.js +5 -5
  38. package/hooks/on-module-destroy.hook.js +5 -5
  39. package/hooks/on-module-init.hook.js +5 -5
  40. package/index.js +12 -12
  41. package/injector/compiler.js +1 -1
  42. package/injector/helpers/transient-instances.js +2 -2
  43. package/injector/index.js +5 -5
  44. package/injector/injector.js +13 -13
  45. package/injector/inquirer/index.js +1 -1
  46. package/injector/instance-links-host.js +1 -1
  47. package/injector/instance-loader.js +1 -1
  48. package/injector/instance-wrapper.js +7 -7
  49. package/injector/internal-core-module.js +3 -3
  50. package/injector/module-ref.js +1 -1
  51. package/injector/module-token-factory.js +5 -4
  52. package/injector/module.js +18 -18
  53. package/injector/modules-container.js +1 -1
  54. package/interceptors/interceptors-consumer.js +4 -4
  55. package/interceptors/interceptors-context-creator.js +4 -4
  56. package/metadata-scanner.js +4 -4
  57. package/middleware/builder.js +3 -3
  58. package/middleware/container.d.ts +0 -1
  59. package/middleware/container.js +2 -6
  60. package/middleware/index.js +1 -1
  61. package/middleware/middleware-module.js +6 -6
  62. package/middleware/routes-mapper.js +6 -6
  63. package/middleware/utils.js +6 -6
  64. package/nest-application-context.d.ts +5 -0
  65. package/nest-application-context.js +18 -8
  66. package/nest-application.js +13 -14
  67. package/nest-factory.js +9 -6
  68. package/package.json +2 -2
  69. package/pipes/pipes-context-creator.js +4 -4
  70. package/router/index.js +2 -2
  71. package/router/interfaces/index.js +1 -1
  72. package/router/route-path-factory.js +21 -16
  73. package/router/router-exception-filters.js +2 -2
  74. package/router/router-execution-context.js +7 -6
  75. package/router/router-explorer.js +12 -12
  76. package/router/router-module.js +6 -6
  77. package/router/router-response-controller.d.ts +5 -2
  78. package/router/router-response-controller.js +19 -10
  79. package/router/routes-resolver.js +6 -3
  80. package/router/sse-stream.d.ts +8 -2
  81. package/router/sse-stream.js +7 -10
  82. package/router/utils/exclude-route.util.js +1 -1
  83. package/router/utils/flatten-route-paths.util.js +2 -2
  84. package/router/utils/index.js +2 -2
  85. package/scanner.d.ts +18 -2
  86. package/scanner.js +43 -14
  87. package/services/index.js +1 -1
  88. package/services/reflector.service.js +2 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2021 Kamil Mysliwiec <https://kamilmysliwiec.com>
3
+ Copyright (c) 2017-2022 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
@@ -59,6 +59,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
59
59
  #### Principal Sponsors
60
60
  <table style="text-align:center;"><tr>
61
61
  <td><a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
62
+ <td><a href="https://www.redhat.com" target="_blank"><img src="https://nestjs.com/img/red-hat-logo.svg" width="200" valign="middle" /></a></td>
62
63
  <td>
63
64
  <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>
64
65
  <td>
@@ -80,10 +81,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
80
81
  <table style="text-align:center;"><tr><td>
81
82
  <a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
82
83
  <a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
83
- <a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
84
+ <a href="https://www.myleodsc.com/" target="_blank"><img src="https://nestjs.com/img/myleo-logo.png" width="180" valign="middle" /></td><td>
84
85
  <a href="https://careers.meetdandy.com/?gh_src=063ba61e3us" target="_blank"><img src="https://nestjs.com/img/dandy-roles-logo.svg" width="150" valign="middle" /></td><td>
85
86
  <a href="https://www.castlecraft.in" target="_blank"><img src="https://nestjs.com/img/castlecraft-logo.png" width="150" valign="middle" /></td>
86
- <td><a href="https://www.tinystacks.com" target="_blank"><img src="https://nestjs.com/img/tinystacks-logo.png#1" width="140" valign="middle" /></td></tr></table>
87
+ <td><a href="https://www.tinystacks.com" target="_blank"><img src="https://nestjs.com/img/tinystacks-logo.png#1" width="140" valign="middle" /></td>
88
+ <td><a href="https://n.inc" target="_blank"><img src="https://nestjs.com/img/n-inc-logo.svg" width="120" valign="middle" /></td></tr></table>
87
89
 
88
90
  #### Sponsors
89
91
 
@@ -117,6 +119,10 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
117
119
  <td align="center" valign="middle"><a href="https://www.naologic.com/" target="_blank"><img src="https://nestjs.com/img/naologic-logo.svg" width="125" valign="middle" /></a></td>
118
120
  <td align="center" valign="middle"><a href="https://messaged.com/" target="_blank"><img src="https://nestjs.com/img/messaged-logo.png" width="50" valign="middle" /></a></td>
119
121
  <td align="center" valign="middle"><a href="https://triplecore.io" target="_blank"><img src="https://nestjs.com/img/triplecore-logo.svg" width="50" valign="middle" /></a></td>
122
+ <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>
123
+ <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>
124
+ <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>
125
+ <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>
120
126
  </tr></table>
121
127
 
122
128
  ## Backers
package/adapters/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./http-adapter"), exports);
4
+ (0, tslib_1.__exportStar)(require("./http-adapter"), exports);
@@ -94,6 +94,10 @@ class ApplicationConfig {
94
94
  return this.globalRequestGuards;
95
95
  }
96
96
  enableVersioning(options) {
97
+ if (Array.isArray(options.defaultVersion)) {
98
+ // Drop duplicated versions
99
+ options.defaultVersion = Array.from(new Set(options.defaultVersion));
100
+ }
97
101
  this.versioningOptions = options;
98
102
  }
99
103
  getVersioning() {
@@ -10,8 +10,8 @@ const discovery_service_1 = require("./discovery-service");
10
10
  */
11
11
  let DiscoveryModule = class DiscoveryModule {
12
12
  };
13
- DiscoveryModule = tslib_1.__decorate([
14
- common_1.Module({
13
+ DiscoveryModule = (0, tslib_1.__decorate)([
14
+ (0, common_1.Module)({
15
15
  providers: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
16
16
  exports: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
17
17
  })
@@ -13,11 +13,11 @@ let DiscoveryService = class DiscoveryService {
13
13
  }
14
14
  getProviders(options = {}, modules = this.getModules(options)) {
15
15
  const providers = modules.map(item => [...item.providers.values()]);
16
- return common_1.flatten(providers);
16
+ return (0, common_1.flatten)(providers);
17
17
  }
18
18
  getControllers(options = {}, modules = this.getModules(options)) {
19
19
  const controllers = modules.map(item => [...item.controllers.values()]);
20
- return common_1.flatten(controllers);
20
+ return (0, common_1.flatten)(controllers);
21
21
  }
22
22
  getModules(options = {}) {
23
23
  if (!options.include) {
@@ -32,8 +32,8 @@ let DiscoveryService = class DiscoveryService {
32
32
  return moduleRefs.filter(({ metatype }) => include.some(item => item === metatype));
33
33
  }
34
34
  };
35
- DiscoveryService = tslib_1.__decorate([
36
- common_1.Injectable(),
37
- tslib_1.__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
35
+ DiscoveryService = (0, tslib_1.__decorate)([
36
+ (0, common_1.Injectable)(),
37
+ (0, tslib_1.__metadata)("design:paramtypes", [modules_container_1.ModulesContainer])
38
38
  ], DiscoveryService);
39
39
  exports.DiscoveryService = DiscoveryService;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./discovery-module"), exports);
5
- tslib_1.__exportStar(require("./discovery-service"), exports);
4
+ (0, tslib_1.__exportStar)(require("./discovery-module"), exports);
5
+ (0, tslib_1.__exportStar)(require("./discovery-service"), exports);
@@ -0,0 +1,4 @@
1
+ import { RuntimeException } from './runtime.exception';
2
+ export declare class InvalidClassModuleException extends RuntimeException {
3
+ constructor(metatypeUsedAsAModule: any, scope: any[]);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidClassModuleException = void 0;
4
+ const messages_1 = require("../messages");
5
+ const runtime_exception_1 = require("./runtime.exception");
6
+ class InvalidClassModuleException extends runtime_exception_1.RuntimeException {
7
+ constructor(metatypeUsedAsAModule, scope) {
8
+ super((0, messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE)(metatypeUsedAsAModule, scope));
9
+ }
10
+ }
11
+ exports.InvalidClassModuleException = InvalidClassModuleException;
@@ -6,11 +6,11 @@ const messages_1 = require("../messages");
6
6
  const runtime_exception_1 = require("./runtime.exception");
7
7
  class InvalidClassScopeException extends runtime_exception_1.RuntimeException {
8
8
  constructor(metatypeOrToken) {
9
- let name = shared_utils_1.isFunction(metatypeOrToken)
9
+ let name = (0, shared_utils_1.isFunction)(metatypeOrToken)
10
10
  ? metatypeOrToken.name
11
11
  : metatypeOrToken;
12
12
  name = name && name.toString();
13
- super(messages_1.INVALID_CLASS_SCOPE_MESSAGE `${name}`);
13
+ super((0, messages_1.INVALID_CLASS_SCOPE_MESSAGE) `${name}`);
14
14
  }
15
15
  }
16
16
  exports.InvalidClassScopeException = InvalidClassScopeException;
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
5
5
  const runtime_exception_1 = require("./runtime.exception");
6
6
  class InvalidClassException extends runtime_exception_1.RuntimeException {
7
7
  constructor(value) {
8
- super(messages_1.INVALID_CLASS_MESSAGE `${value}`);
8
+ super((0, messages_1.INVALID_CLASS_MESSAGE) `${value}`);
9
9
  }
10
10
  }
11
11
  exports.InvalidClassException = InvalidClassException;
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
5
5
  const runtime_exception_1 = require("./runtime.exception");
6
6
  class InvalidMiddlewareException extends runtime_exception_1.RuntimeException {
7
7
  constructor(name) {
8
- super(messages_1.INVALID_MIDDLEWARE_MESSAGE `${name}`);
8
+ super((0, messages_1.INVALID_MIDDLEWARE_MESSAGE) `${name}`);
9
9
  }
10
10
  }
11
11
  exports.InvalidMiddlewareException = InvalidMiddlewareException;
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
5
5
  const runtime_exception_1 = require("./runtime.exception");
6
6
  class InvalidModuleException extends runtime_exception_1.RuntimeException {
7
7
  constructor(parentModule, index, scope) {
8
- super(messages_1.INVALID_MODULE_MESSAGE(parentModule, index, scope));
8
+ super((0, messages_1.INVALID_MODULE_MESSAGE)(parentModule, index, scope));
9
9
  }
10
10
  }
11
11
  exports.InvalidModuleException = InvalidModuleException;
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
5
5
  const runtime_exception_1 = require("./runtime.exception");
6
6
  class UndefinedDependencyException extends runtime_exception_1.RuntimeException {
7
7
  constructor(type, undefinedDependencyContext, module) {
8
- super(messages_1.UNKNOWN_DEPENDENCIES_MESSAGE(type, undefinedDependencyContext, module));
8
+ super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, undefinedDependencyContext, module));
9
9
  }
10
10
  }
11
11
  exports.UndefinedDependencyException = UndefinedDependencyException;
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
5
5
  const runtime_exception_1 = require("./runtime.exception");
6
6
  class UndefinedForwardRefException extends runtime_exception_1.RuntimeException {
7
7
  constructor(scope) {
8
- super(messages_1.UNDEFINED_FORWARDREF_MESSAGE(scope));
8
+ super((0, messages_1.UNDEFINED_FORWARDREF_MESSAGE)(scope));
9
9
  }
10
10
  }
11
11
  exports.UndefinedForwardRefException = UndefinedForwardRefException;
@@ -5,7 +5,7 @@ const runtime_exception_1 = require("./runtime.exception");
5
5
  const messages_1 = require("../messages");
6
6
  class UndefinedModuleException extends runtime_exception_1.RuntimeException {
7
7
  constructor(parentModule, index, scope) {
8
- super(messages_1.UNDEFINED_MODULE_MESSAGE(parentModule, index, scope));
8
+ super((0, messages_1.UNDEFINED_MODULE_MESSAGE)(parentModule, index, scope));
9
9
  }
10
10
  }
11
11
  exports.UndefinedModuleException = UndefinedModuleException;
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
5
5
  const runtime_exception_1 = require("./runtime.exception");
6
6
  class UnknownDependenciesException extends runtime_exception_1.RuntimeException {
7
7
  constructor(type, unknownDependencyContext, module) {
8
- super(messages_1.UNKNOWN_DEPENDENCIES_MESSAGE(type, unknownDependencyContext, module));
8
+ super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, unknownDependencyContext, module));
9
9
  }
10
10
  }
11
11
  exports.UnknownDependenciesException = UnknownDependenciesException;
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
5
5
  const runtime_exception_1 = require("./runtime.exception");
6
6
  class UnknownExportException extends runtime_exception_1.RuntimeException {
7
7
  constructor(token, moduleName) {
8
- super(messages_1.UNKNOWN_EXPORT_MESSAGE(token, moduleName));
8
+ super((0, messages_1.UNKNOWN_EXPORT_MESSAGE)(token, moduleName));
9
9
  }
10
10
  }
11
11
  exports.UnknownExportException = UnknownExportException;
@@ -1,10 +1,11 @@
1
- import { Type } from '@nestjs/common';
1
+ import type { ForwardReference, Type } from '@nestjs/common';
2
2
  import { InjectorDependencyContext } from '../injector/injector';
3
3
  import { Module } from '../injector/module';
4
4
  export declare const UNKNOWN_DEPENDENCIES_MESSAGE: (type: string | symbol, unknownDependencyContext: InjectorDependencyContext, module: Module) => string;
5
5
  export declare const INVALID_MIDDLEWARE_MESSAGE: (text: TemplateStringsArray, name: string) => string;
6
6
  export declare const UNDEFINED_FORWARDREF_MESSAGE: (scope: Type<any>[]) => string;
7
7
  export declare const INVALID_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
8
+ export declare const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE: (metatypeUsedAsAModule: Type | ForwardReference, scope: any[]) => string;
8
9
  export declare const UNDEFINED_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
9
10
  export declare const UNKNOWN_EXPORT_MESSAGE: (token: string | symbol, module: string) => string;
10
11
  export declare const INVALID_CLASS_MESSAGE: (text: TemplateStringsArray, value: any) => string;
@@ -1,17 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = exports.INVALID_EXCEPTION_FILTER = exports.UNHANDLED_RUNTIME_EXCEPTION = exports.UNKNOWN_REQUEST_MAPPING = exports.INVALID_MIDDLEWARE_CONFIGURATION = exports.INVALID_CLASS_SCOPE_MESSAGE = exports.INVALID_CLASS_MESSAGE = exports.UNKNOWN_EXPORT_MESSAGE = exports.UNDEFINED_MODULE_MESSAGE = exports.INVALID_MODULE_MESSAGE = exports.UNDEFINED_FORWARDREF_MESSAGE = exports.INVALID_MIDDLEWARE_MESSAGE = exports.UNKNOWN_DEPENDENCIES_MESSAGE = void 0;
3
+ exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = exports.INVALID_EXCEPTION_FILTER = exports.UNHANDLED_RUNTIME_EXCEPTION = exports.UNKNOWN_REQUEST_MAPPING = exports.INVALID_MIDDLEWARE_CONFIGURATION = exports.INVALID_CLASS_SCOPE_MESSAGE = exports.INVALID_CLASS_MESSAGE = exports.UNKNOWN_EXPORT_MESSAGE = exports.UNDEFINED_MODULE_MESSAGE = exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = exports.INVALID_MODULE_MESSAGE = exports.UNDEFINED_FORWARDREF_MESSAGE = exports.INVALID_MIDDLEWARE_MESSAGE = exports.UNKNOWN_DEPENDENCIES_MESSAGE = void 0;
4
4
  const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
5
  /**
6
- * Returns the name of an instance
6
+ * Returns the name of an instance or `undefined`
7
7
  * @param instance The instance which should get the name from
8
8
  */
9
9
  const getInstanceName = (instance) => {
10
- var _a, _b, _c;
10
+ var _a, _b, _c, _d, _e;
11
11
  if ((_a = instance) === null || _a === void 0 ? void 0 : _a.forwardRef) {
12
12
  return (_b = instance.forwardRef()) === null || _b === void 0 ? void 0 : _b.name;
13
13
  }
14
- return (_c = instance) === null || _c === void 0 ? void 0 : _c.name;
14
+ if ((_c = instance) === null || _c === void 0 ? void 0 : _c.module) {
15
+ return (_d = instance.module) === null || _d === void 0 ? void 0 : _d.name;
16
+ }
17
+ return (_e = instance) === null || _e === void 0 ? void 0 : _e.name;
15
18
  };
16
19
  /**
17
20
  * Returns the name of the dependency
@@ -23,7 +26,7 @@ const getDependencyName = (dependency) =>
23
26
  // use class name
24
27
  getInstanceName(dependency) ||
25
28
  // use injection token (symbol)
26
- (shared_utils_1.isSymbol(dependency) && dependency.toString()) ||
29
+ ((0, shared_utils_1.isSymbol)(dependency) && dependency.toString()) ||
27
30
  // use string directly
28
31
  dependency ||
29
32
  // otherwise
@@ -48,7 +51,7 @@ Potential solutions:
48
51
  imports: [ /* the Module containing ${dependencyName} */ ]
49
52
  })
50
53
  `;
51
- if (shared_utils_1.isNil(index)) {
54
+ if ((0, shared_utils_1.isNil)(index)) {
52
55
  message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
53
56
  return message;
54
57
  }
@@ -67,16 +70,26 @@ const UNDEFINED_FORWARDREF_MESSAGE = (scope) => `Nest cannot create the module i
67
70
 
68
71
  (Read more: https://docs.nestjs.com/fundamentals/circular-dependency)
69
72
  Scope [${stringifyScope(scope)}]
70
- `;
73
+ `;
71
74
  exports.UNDEFINED_FORWARDREF_MESSAGE = UNDEFINED_FORWARDREF_MESSAGE;
72
75
  const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
73
76
  const parentModuleName = (parentModule === null || parentModule === void 0 ? void 0 : parentModule.name) || 'module';
74
77
  return `Nest cannot create the ${parentModuleName} instance.
75
- Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
78
+ Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
76
79
 
77
80
  Scope [${stringifyScope(scope)}]`;
78
81
  };
79
82
  exports.INVALID_MODULE_MESSAGE = INVALID_MODULE_MESSAGE;
83
+ const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
84
+ const metatypeName = getInstanceName(metatypeUsedAsAModule) || 'found';
85
+ // TODO(v9): Edit the message below:
86
+ return `In the next major version, Nest will not allow classes annotated with @Injectable(), @Catch(), and @Controller() decorators to appear in the "imports" array of a module.
87
+ Please remove "${metatypeName}" (including forwarded occurrences, if any) from all of the "imports" arrays.
88
+
89
+ Scope [${stringifyScope(scope)}]
90
+ `;
91
+ };
92
+ exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = USING_INVALID_CLASS_AS_A_MODULE_MESSAGE;
80
93
  const UNDEFINED_MODULE_MESSAGE = (parentModule, index, scope) => {
81
94
  const parentModuleName = (parentModule === null || parentModule === void 0 ? void 0 : parentModule.name) || 'module';
82
95
  return `Nest cannot create the ${parentModuleName} instance.
@@ -90,7 +103,7 @@ Scope [${stringifyScope(scope)}]`;
90
103
  };
91
104
  exports.UNDEFINED_MODULE_MESSAGE = UNDEFINED_MODULE_MESSAGE;
92
105
  const UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
93
- token = shared_utils_1.isSymbol(token) ? token.toString() : token;
106
+ token = (0, shared_utils_1.isSymbol)(token) ? token.toString() : token;
94
107
  return `Nest cannot export a provider/module that is not a part of the currently processed module (${module}). Please verify whether the exported ${token} is available in this particular context.
95
108
 
96
109
  Possible Solutions:
@@ -12,11 +12,11 @@ class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
12
12
  this.container = container;
13
13
  }
14
14
  createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
15
- if (shared_utils_1.isEmpty(metadata)) {
15
+ if ((0, shared_utils_1.isEmpty)(metadata)) {
16
16
  return [];
17
17
  }
18
- return iterare_1.iterate(metadata)
19
- .filter(instance => instance && (shared_utils_1.isFunction(instance.catch) || instance.name))
18
+ return (0, iterare_1.iterate)(metadata)
19
+ .filter(instance => instance && ((0, shared_utils_1.isFunction)(instance.catch) || instance.name))
20
20
  .map(filter => this.getFilterInstance(filter, contextId, inquirerId))
21
21
  .filter(item => !!item)
22
22
  .map(instance => ({
@@ -17,7 +17,7 @@ class BaseExceptionFilter {
17
17
  return this.handleUnknownError(exception, host, applicationRef);
18
18
  }
19
19
  const res = exception.getResponse();
20
- const message = shared_utils_1.isObject(res)
20
+ const message = (0, shared_utils_1.isObject)(res)
21
21
  ? res
22
22
  : {
23
23
  statusCode: exception.getStatus(),
@@ -42,7 +42,7 @@ class BaseExceptionFilter {
42
42
  return BaseExceptionFilter.logger.error(exception);
43
43
  }
44
44
  isExceptionObject(err) {
45
- return shared_utils_1.isObject(err) && !!err.message;
45
+ return (0, shared_utils_1.isObject)(err) && !!err.message;
46
46
  }
47
47
  /**
48
48
  * Checks if the thrown error comes from the "http-errors" library.
@@ -53,9 +53,9 @@ class BaseExceptionFilter {
53
53
  }
54
54
  }
55
55
  BaseExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');
56
- tslib_1.__decorate([
57
- common_1.Optional(),
58
- common_1.Inject(),
59
- tslib_1.__metadata("design:type", http_adapter_host_1.HttpAdapterHost)
56
+ (0, tslib_1.__decorate)([
57
+ (0, common_1.Optional)(),
58
+ (0, common_1.Inject)(),
59
+ (0, tslib_1.__metadata)("design:type", http_adapter_host_1.HttpAdapterHost)
60
60
  ], BaseExceptionFilter.prototype, "httpAdapterHost", void 0);
61
61
  exports.BaseExceptionFilter = BaseExceptionFilter;
@@ -22,7 +22,7 @@ class ExceptionsHandler extends base_exception_filter_1.BaseExceptionFilter {
22
22
  this.filters = filters;
23
23
  }
24
24
  invokeCustomFilters(exception, ctx) {
25
- if (shared_utils_1.isEmpty(this.filters)) {
25
+ if ((0, shared_utils_1.isEmpty)(this.filters)) {
26
26
  return false;
27
27
  }
28
28
  const isInstanceOf = (metatype) => exception instanceof metatype;
@@ -16,7 +16,7 @@ class ExternalExceptionFilterContext extends base_exception_filter_context_1.Bas
16
16
  this.moduleContext = module;
17
17
  const exceptionHandler = new external_exceptions_handler_1.ExternalExceptionsHandler();
18
18
  const filters = this.createContext(instance, callback, constants_1.EXCEPTION_FILTERS_METADATA, contextId, inquirerId);
19
- if (shared_utils_1.isEmpty(filters)) {
19
+ if ((0, shared_utils_1.isEmpty)(filters)) {
20
20
  return exceptionHandler;
21
21
  }
22
22
  exceptionHandler.setCustomFilters(filters.reverse());
@@ -31,7 +31,7 @@ class ExternalExceptionFilterContext extends base_exception_filter_context_1.Bas
31
31
  return globalFilters;
32
32
  }
33
33
  const scopedFilterWrappers = this.config.getGlobalRequestFilters();
34
- const scopedFilters = iterare_1.iterate(scopedFilterWrappers)
34
+ const scopedFilters = (0, iterare_1.iterate)(scopedFilterWrappers)
35
35
  .map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
36
36
  .filter(host => !!host)
37
37
  .map(host => host.instance)
@@ -23,7 +23,7 @@ class ExternalExceptionsHandler extends external_exception_filter_1.ExternalExce
23
23
  this.filters = filters;
24
24
  }
25
25
  invokeCustomFilters(exception, host) {
26
- if (shared_utils_1.isEmpty(this.filters)) {
26
+ if ((0, shared_utils_1.isEmpty)(this.filters)) {
27
27
  return null;
28
28
  }
29
29
  const isInstanceOf = (metatype) => exception instanceof metatype;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./base-exception-filter"), exports);
4
+ (0, tslib_1.__exportStar)(require("./base-exception-filter"), exports);
@@ -6,7 +6,7 @@ const rxjs_1 = require("rxjs");
6
6
  const execution_context_host_1 = require("../helpers/execution-context-host");
7
7
  class GuardsConsumer {
8
8
  async tryActivate(guards, args, instance, callback, type) {
9
- if (!guards || shared_utils_1.isEmpty(guards)) {
9
+ if (!guards || (0, shared_utils_1.isEmpty)(guards)) {
10
10
  return true;
11
11
  }
12
12
  const context = this.createContext(args, instance, callback);
@@ -25,7 +25,7 @@ class GuardsConsumer {
25
25
  }
26
26
  async pickResult(result) {
27
27
  if (result instanceof rxjs_1.Observable) {
28
- return rxjs_1.lastValueFrom(result);
28
+ return (0, rxjs_1.lastValueFrom)(result);
29
29
  }
30
30
  return result;
31
31
  }
@@ -17,13 +17,13 @@ class GuardsContextCreator extends context_creator_1.ContextCreator {
17
17
  return this.createContext(instance, callback, constants_1.GUARDS_METADATA, contextId, inquirerId);
18
18
  }
19
19
  createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
20
- if (shared_utils_1.isEmpty(metadata)) {
20
+ if ((0, shared_utils_1.isEmpty)(metadata)) {
21
21
  return [];
22
22
  }
23
- return iterare_1.iterate(metadata)
23
+ return (0, iterare_1.iterate)(metadata)
24
24
  .filter((guard) => guard && (guard.name || guard.canActivate))
25
25
  .map(guard => this.getGuardInstance(guard, contextId, inquirerId))
26
- .filter((guard) => guard && shared_utils_1.isFunction(guard.canActivate))
26
+ .filter((guard) => guard && (0, shared_utils_1.isFunction)(guard.canActivate))
27
27
  .toArray();
28
28
  }
29
29
  getGuardInstance(metatype, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
@@ -59,7 +59,7 @@ class GuardsContextCreator extends context_creator_1.ContextCreator {
59
59
  return globalGuards;
60
60
  }
61
61
  const scopedGuardWrappers = this.config.getGlobalRequestGuards();
62
- const scopedGuards = iterare_1.iterate(scopedGuardWrappers)
62
+ const scopedGuards = (0, iterare_1.iterate)(scopedGuardWrappers)
63
63
  .map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
64
64
  .filter(host => !!host)
65
65
  .map(host => host.instance)
@@ -19,11 +19,15 @@ class ContextUtils {
19
19
  return Reflect.getMetadata(constants_1.RESPONSE_PASSTHROUGH_METADATA, instance.constructor, methodName);
20
20
  }
21
21
  getArgumentsLength(keys, metadata) {
22
- return Math.max(...keys.map(key => metadata[key].index)) + 1;
22
+ return keys.length
23
+ ? Math.max(...keys.map(key => metadata[key].index)) + 1
24
+ : 0;
23
25
  }
24
26
  createNullArray(length) {
25
- // eslint-disable-next-line prefer-spread
26
- return Array.apply(null, { length }).fill(undefined);
27
+ const a = new Array(length);
28
+ for (let i = 0; i < length; ++i)
29
+ a[i] = undefined;
30
+ return a;
27
31
  }
28
32
  mergeParamsMetatypes(paramsProperties, paramtypes) {
29
33
  if (!paramtypes) {
@@ -32,7 +36,7 @@ class ContextUtils {
32
36
  return paramsProperties.map(param => (Object.assign(Object.assign({}, param), { metatype: paramtypes[param.index] })));
33
37
  }
34
38
  getCustomFactory(factory, data, contextFactory) {
35
- return shared_utils_1.isFunction(factory)
39
+ return (0, shared_utils_1.isFunction)(factory)
36
40
  ? (...args) => factory(data, contextFactory(args))
37
41
  : () => null;
38
42
  }
@@ -143,13 +143,13 @@ class ExternalContextCreator {
143
143
  return paramsOptions.length ? pipesFn : null;
144
144
  }
145
145
  async getParamValue(value, { metatype, type, data }, pipes) {
146
- return shared_utils_1.isEmpty(pipes)
146
+ return (0, shared_utils_1.isEmpty)(pipes)
147
147
  ? value
148
148
  : this.pipesConsumer.apply(value, { metatype, type, data }, pipes);
149
149
  }
150
150
  async transformToResult(resultOrDeferred) {
151
- if (resultOrDeferred && shared_utils_1.isFunction(resultOrDeferred.subscribe)) {
152
- return rxjs_1.lastValueFrom(resultOrDeferred);
151
+ if ((0, rxjs_1.isObservable)(resultOrDeferred)) {
152
+ return (0, rxjs_1.lastValueFrom)(resultOrDeferred);
153
153
  }
154
154
  return resultOrDeferred;
155
155
  }
package/helpers/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./context-id-factory"), exports);
5
- tslib_1.__exportStar(require("./http-adapter-host"), exports);
4
+ (0, tslib_1.__exportStar)(require("./context-id-factory"), exports);
5
+ (0, tslib_1.__exportStar)(require("./http-adapter-host"), exports);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./external-handler-metadata.interface"), exports);
5
- tslib_1.__exportStar(require("./params-metadata.interface"), exports);
4
+ (0, tslib_1.__exportStar)(require("./external-handler-metadata.interface"), exports);
5
+ (0, tslib_1.__exportStar)(require("./params-metadata.interface"), exports);
@@ -8,19 +8,21 @@ exports.MODULE_INIT_MESSAGE = MODULE_INIT_MESSAGE;
8
8
  const ROUTE_MAPPED_MESSAGE = (path, method) => `Mapped {${path}, ${request_method_enum_1.RequestMethod[method]}} route`;
9
9
  exports.ROUTE_MAPPED_MESSAGE = ROUTE_MAPPED_MESSAGE;
10
10
  const VERSIONED_ROUTE_MAPPED_MESSAGE = (path, method, version) => {
11
- if (version === version_options_interface_1.VERSION_NEUTRAL) {
12
- version = 'Neutral';
13
- }
14
- return `Mapped {${path}, ${request_method_enum_1.RequestMethod[method]}} (version: ${version}) route`;
11
+ const controllerVersions = Array.isArray(version) ? version : [version];
12
+ const versions = controllerVersions
13
+ .map(version => (version === version_options_interface_1.VERSION_NEUTRAL ? 'Neutral' : version))
14
+ .join(',');
15
+ return `Mapped {${path}, ${request_method_enum_1.RequestMethod[method]}} (version: ${versions}) route`;
15
16
  };
16
17
  exports.VERSIONED_ROUTE_MAPPED_MESSAGE = VERSIONED_ROUTE_MAPPED_MESSAGE;
17
18
  const CONTROLLER_MAPPING_MESSAGE = (name, path) => `${name} {${path}}:`;
18
19
  exports.CONTROLLER_MAPPING_MESSAGE = CONTROLLER_MAPPING_MESSAGE;
19
20
  const VERSIONED_CONTROLLER_MAPPING_MESSAGE = (name, path, version) => {
20
- if (version === version_options_interface_1.VERSION_NEUTRAL) {
21
- version = 'Neutral';
22
- }
23
- return `${name} {${path}} (version: ${version}):`;
21
+ const controllerVersions = Array.isArray(version) ? version : [version];
22
+ const versions = controllerVersions
23
+ .map(version => (version === version_options_interface_1.VERSION_NEUTRAL ? 'Neutral' : version))
24
+ .join(',');
25
+ return `${name} {${path}} (version: ${versions}):`;
24
26
  };
25
27
  exports.VERSIONED_CONTROLLER_MAPPING_MESSAGE = VERSIONED_CONTROLLER_MAPPING_MESSAGE;
26
28
  const INVALID_EXECUTION_CONTEXT = (methodName, currentContext) => `Calling ${methodName} is not allowed in this context. Your current execution context is "${currentContext}".`;
@@ -10,14 +10,14 @@ const transient_instances_1 = require("../injector/helpers/transient-instances")
10
10
  * @param instance The instance which should be checked
11
11
  */
12
12
  function hasBeforeApplicationShutdownHook(instance) {
13
- return shared_utils_1.isFunction(instance.beforeApplicationShutdown);
13
+ return (0, shared_utils_1.isFunction)(instance.beforeApplicationShutdown);
14
14
  }
15
15
  /**
16
16
  * Calls the given instances
17
17
  */
18
18
  function callOperator(instances, signal) {
19
- return iterare_1.iterate(instances)
20
- .filter(instance => !shared_utils_1.isNil(instance))
19
+ return (0, iterare_1.iterate)(instances)
20
+ .filter(instance => !(0, shared_utils_1.isNil)(instance))
21
21
  .filter(hasBeforeApplicationShutdownHook)
22
22
  .map(async (instance) => instance.beforeApplicationShutdown(signal))
23
23
  .toArray();
@@ -38,9 +38,9 @@ async function callBeforeAppShutdownHook(module, signal) {
38
38
  ...module.injectables,
39
39
  ...module.middlewares,
40
40
  ];
41
- const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
41
+ const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
42
42
  await Promise.all(callOperator(nonTransientInstances, signal));
43
- const transientInstances = transient_instances_1.getTransientInstances(instances);
43
+ const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
44
44
  await Promise.all(callOperator(transientInstances, signal));
45
45
  const moduleClassInstance = moduleClassHost.instance;
46
46
  if (moduleClassInstance &&
package/hooks/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./on-app-bootstrap.hook"), exports);
5
- tslib_1.__exportStar(require("./on-app-shutdown.hook"), exports);
6
- tslib_1.__exportStar(require("./on-module-destroy.hook"), exports);
7
- tslib_1.__exportStar(require("./on-module-init.hook"), exports);
8
- tslib_1.__exportStar(require("./before-app-shutdown.hook"), exports);
4
+ (0, tslib_1.__exportStar)(require("./on-app-bootstrap.hook"), exports);
5
+ (0, tslib_1.__exportStar)(require("./on-app-shutdown.hook"), exports);
6
+ (0, tslib_1.__exportStar)(require("./on-module-destroy.hook"), exports);
7
+ (0, tslib_1.__exportStar)(require("./on-module-init.hook"), exports);
8
+ (0, tslib_1.__exportStar)(require("./before-app-shutdown.hook"), exports);