@nestjs/core 8.4.0 → 8.4.3
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/discovery/discovery-module.js +1 -1
- package/discovery/discovery-service.js +3 -3
- package/errors/exceptions/invalid-class-module.exception.js +1 -1
- package/errors/exceptions/invalid-class-scope.exception.js +2 -2
- package/errors/exceptions/invalid-class.exception.js +1 -1
- package/errors/exceptions/invalid-middleware.exception.js +1 -1
- package/errors/exceptions/invalid-module.exception.js +1 -1
- package/errors/exceptions/undefined-dependency.exception.js +1 -1
- package/errors/exceptions/undefined-forwardref.exception.js +1 -1
- package/errors/exceptions/undefined-module.exception.js +1 -1
- package/errors/exceptions/unknown-dependencies.exception.js +1 -1
- package/errors/exceptions/unknown-export.exception.js +1 -1
- package/errors/messages.js +9 -9
- package/exceptions/base-exception-filter-context.js +3 -3
- package/exceptions/base-exception-filter.js +4 -4
- package/exceptions/exceptions-handler.js +1 -1
- package/exceptions/external-exception-filter-context.js +2 -2
- package/exceptions/external-exceptions-handler.js +1 -1
- package/guards/guards-consumer.js +2 -2
- package/guards/guards-context-creator.js +4 -4
- package/helpers/context-utils.js +1 -1
- package/helpers/external-context-creator.js +3 -3
- package/hooks/before-app-shutdown.hook.js +5 -5
- package/hooks/on-app-bootstrap.hook.js +5 -5
- package/hooks/on-app-shutdown.hook.js +5 -5
- package/hooks/on-module-destroy.hook.js +5 -5
- package/hooks/on-module-init.hook.js +5 -5
- package/injector/helpers/transient-instances.js +2 -2
- package/injector/injector.js +16 -15
- package/injector/instance-links-host.js +1 -2
- package/injector/instance-loader.js +1 -1
- package/injector/instance-wrapper.js +6 -6
- package/injector/internal-core-module.js +2 -2
- package/injector/module-ref.js +1 -1
- package/injector/module-token-factory.js +4 -4
- package/injector/module.js +21 -24
- package/injector/modules-container.js +1 -1
- package/interceptors/interceptors-consumer.js +4 -4
- package/interceptors/interceptors-context-creator.js +4 -4
- package/metadata-scanner.js +4 -4
- package/middleware/builder.js +3 -3
- package/middleware/container.js +1 -1
- package/middleware/middleware-module.js +9 -8
- package/middleware/routes-mapper.js +6 -6
- package/middleware/utils.js +6 -6
- package/nest-application-context.js +9 -10
- package/nest-application.js +13 -13
- package/nest-factory.js +6 -6
- package/package.json +2 -2
- package/pipes/pipes-context-creator.js +4 -4
- package/router/route-path-factory.js +8 -8
- package/router/router-exception-filters.js +2 -2
- package/router/router-execution-context.js +4 -4
- package/router/router-explorer.js +14 -14
- package/router/router-module.js +4 -4
- package/router/router-response-controller.js +6 -6
- package/router/routes-resolver.js +2 -2
- package/router/sse-stream.js +1 -1
- package/router/utils/exclude-route.util.js +1 -1
- package/router/utils/flatten-route-paths.util.js +2 -2
- package/scanner.js +9 -9
- package/services/reflector.service.js +2 -2
|
@@ -11,7 +11,7 @@ const discovery_service_1 = require("./discovery-service");
|
|
|
11
11
|
let DiscoveryModule = class DiscoveryModule {
|
|
12
12
|
};
|
|
13
13
|
DiscoveryModule = tslib_1.__decorate([
|
|
14
|
-
common_1.Module({
|
|
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) {
|
|
@@ -33,7 +33,7 @@ let DiscoveryService = class DiscoveryService {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
DiscoveryService = tslib_1.__decorate([
|
|
36
|
-
common_1.Injectable(),
|
|
36
|
+
(0, common_1.Injectable)(),
|
|
37
37
|
tslib_1.__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
|
|
38
38
|
], DiscoveryService);
|
|
39
39
|
exports.DiscoveryService = DiscoveryService;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class InvalidClassModuleException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(metatypeUsedAsAModule, scope) {
|
|
8
|
-
super(messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE(metatypeUsedAsAModule, scope));
|
|
8
|
+
super((0, messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE)(metatypeUsedAsAModule, scope));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
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;
|
package/errors/messages.js
CHANGED
|
@@ -7,14 +7,14 @@ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
|
7
7
|
* @param instance The instance which should get the name from
|
|
8
8
|
*/
|
|
9
9
|
const getInstanceName = (instance) => {
|
|
10
|
-
var _a, _b
|
|
11
|
-
if (
|
|
12
|
-
return (
|
|
10
|
+
var _a, _b;
|
|
11
|
+
if (instance === null || instance === void 0 ? void 0 : instance.forwardRef) {
|
|
12
|
+
return (_a = instance.forwardRef()) === null || _a === void 0 ? void 0 : _a.name;
|
|
13
13
|
}
|
|
14
|
-
if (
|
|
15
|
-
return (
|
|
14
|
+
if (instance === null || instance === void 0 ? void 0 : instance.module) {
|
|
15
|
+
return (_b = instance.module) === null || _b === void 0 ? void 0 : _b.name;
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return instance === null || instance === void 0 ? void 0 : instance.name;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Returns the name of the dependency
|
|
@@ -26,7 +26,7 @@ const getDependencyName = (dependency) =>
|
|
|
26
26
|
// use class name
|
|
27
27
|
getInstanceName(dependency) ||
|
|
28
28
|
// use injection token (symbol)
|
|
29
|
-
(shared_utils_1.isSymbol(dependency) && dependency.toString()) ||
|
|
29
|
+
((0, shared_utils_1.isSymbol)(dependency) && dependency.toString()) ||
|
|
30
30
|
// use string directly
|
|
31
31
|
dependency ||
|
|
32
32
|
// otherwise
|
|
@@ -51,7 +51,7 @@ Potential solutions:
|
|
|
51
51
|
imports: [ /* the Module containing ${dependencyName} */ ]
|
|
52
52
|
})
|
|
53
53
|
`;
|
|
54
|
-
if (shared_utils_1.isNil(index)) {
|
|
54
|
+
if ((0, shared_utils_1.isNil)(index)) {
|
|
55
55
|
message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
|
|
56
56
|
return message;
|
|
57
57
|
}
|
|
@@ -103,7 +103,7 @@ Scope [${stringifyScope(scope)}]`;
|
|
|
103
103
|
};
|
|
104
104
|
exports.UNDEFINED_MODULE_MESSAGE = UNDEFINED_MODULE_MESSAGE;
|
|
105
105
|
const UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
|
|
106
|
-
token = shared_utils_1.isSymbol(token) ? token.toString() : token;
|
|
106
|
+
token = (0, shared_utils_1.isSymbol)(token) ? token.toString() : token;
|
|
107
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.
|
|
108
108
|
|
|
109
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.
|
|
@@ -54,8 +54,8 @@ class BaseExceptionFilter {
|
|
|
54
54
|
}
|
|
55
55
|
BaseExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');
|
|
56
56
|
tslib_1.__decorate([
|
|
57
|
-
common_1.Optional(),
|
|
58
|
-
common_1.Inject(),
|
|
57
|
+
(0, common_1.Optional)(),
|
|
58
|
+
(0, common_1.Inject)(),
|
|
59
59
|
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;
|
|
@@ -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)
|
package/helpers/context-utils.js
CHANGED
|
@@ -36,7 +36,7 @@ class ContextUtils {
|
|
|
36
36
|
return paramsProperties.map(param => (Object.assign(Object.assign({}, param), { metatype: paramtypes[param.index] })));
|
|
37
37
|
}
|
|
38
38
|
getCustomFactory(factory, data, contextFactory) {
|
|
39
|
-
return shared_utils_1.isFunction(factory)
|
|
39
|
+
return (0, shared_utils_1.isFunction)(factory)
|
|
40
40
|
? (...args) => factory(data, contextFactory(args))
|
|
41
41
|
: () => null;
|
|
42
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 (rxjs_1.isObservable(resultOrDeferred)) {
|
|
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
|
}
|
|
@@ -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 &&
|
|
@@ -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 hasOnAppBootstrapHook(instance) {
|
|
13
|
-
return shared_utils_1.isFunction(instance.onApplicationBootstrap);
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onApplicationBootstrap);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances) {
|
|
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(hasOnAppBootstrapHook)
|
|
22
22
|
.map(async (instance) => instance.onApplicationBootstrap())
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callModuleBootstrapHook(module) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
42
|
+
const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances));
|
|
44
|
-
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
|
+
const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances));
|
|
46
46
|
// Call the instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
|
@@ -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 hasOnAppShutdownHook(instance) {
|
|
13
|
-
return shared_utils_1.isFunction(instance.onApplicationShutdown);
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onApplicationShutdown);
|
|
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(hasOnAppShutdownHook)
|
|
22
22
|
.map(async (instance) => instance.onApplicationShutdown(signal))
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callAppShutdownHook(module, signal) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
42
|
+
const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances, signal));
|
|
44
|
-
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
|
+
const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances, signal));
|
|
46
46
|
// Call the instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
|
@@ -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 hasOnModuleDestroyHook(instance) {
|
|
13
|
-
return shared_utils_1.isFunction(instance.onModuleDestroy);
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onModuleDestroy);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances onModuleDestroy hook
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances) {
|
|
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(hasOnModuleDestroyHook)
|
|
22
22
|
.map(async (instance) => instance.onModuleDestroy())
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callModuleDestroyHook(module) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
42
|
+
const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances));
|
|
44
|
-
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
|
+
const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances));
|
|
46
46
|
// Call the module instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
|
@@ -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 hasOnModuleInitHook(instance) {
|
|
13
|
-
return shared_utils_1.isFunction(instance.onModuleInit);
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onModuleInit);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances) {
|
|
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(hasOnModuleInitHook)
|
|
22
22
|
.map(async (instance) => instance.onModuleInit())
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callModuleInitHook(module) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
42
|
+
const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances));
|
|
44
|
-
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
|
+
const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances));
|
|
46
46
|
// Call the instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
|
@@ -7,7 +7,7 @@ const iterare_1 = require("iterare");
|
|
|
7
7
|
* @param instances The instances which should be checked whether they are transcient
|
|
8
8
|
*/
|
|
9
9
|
function getTransientInstances(instances) {
|
|
10
|
-
return iterare_1.iterate(instances)
|
|
10
|
+
return (0, iterare_1.iterate)(instances)
|
|
11
11
|
.filter(([_, wrapper]) => wrapper.isDependencyTreeStatic())
|
|
12
12
|
.map(([_, wrapper]) => wrapper.getStaticTransientInstances())
|
|
13
13
|
.flatten()
|
|
@@ -21,7 +21,7 @@ exports.getTransientInstances = getTransientInstances;
|
|
|
21
21
|
* @param instances The instances which should be checked whether they are transcient
|
|
22
22
|
*/
|
|
23
23
|
function getNonTransientInstances(instances) {
|
|
24
|
-
return iterare_1.iterate(instances)
|
|
24
|
+
return (0, iterare_1.iterate)(instances)
|
|
25
25
|
.filter(([key, wrapper]) => wrapper.isDependencyTreeStatic() && !wrapper.isTransient)
|
|
26
26
|
.map(([key, { instance }]) => instance)
|
|
27
27
|
.toArray();
|
package/injector/injector.js
CHANGED
|
@@ -37,7 +37,7 @@ class Injector {
|
|
|
37
37
|
const token = wrapper.token || wrapper.name;
|
|
38
38
|
const { inject } = wrapper;
|
|
39
39
|
const targetWrapper = collection.get(token);
|
|
40
|
-
if (shared_utils_1.isUndefined(targetWrapper)) {
|
|
40
|
+
if ((0, shared_utils_1.isUndefined)(targetWrapper)) {
|
|
41
41
|
throw new runtime_exception_1.RuntimeException();
|
|
42
42
|
}
|
|
43
43
|
if (instanceHost.isResolved) {
|
|
@@ -54,7 +54,7 @@ class Injector {
|
|
|
54
54
|
async loadMiddleware(wrapper, collection, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
55
55
|
const { metatype, token } = wrapper;
|
|
56
56
|
const targetWrapper = collection.get(token);
|
|
57
|
-
if (!shared_utils_1.isUndefined(targetWrapper.instance)) {
|
|
57
|
+
if (!(0, shared_utils_1.isUndefined)(targetWrapper.instance)) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
targetWrapper.instance = Object.create(metatype.prototype);
|
|
@@ -89,7 +89,7 @@ class Injector {
|
|
|
89
89
|
const deps = await this.loadCtorMetadata(metadata, contextId, inquirer, parentInquirer);
|
|
90
90
|
return callback(deps);
|
|
91
91
|
}
|
|
92
|
-
const isFactoryProvider = !shared_utils_1.isNil(inject);
|
|
92
|
+
const isFactoryProvider = !(0, shared_utils_1.isNil)(inject);
|
|
93
93
|
const [dependencies, optionalDependenciesIds] = isFactoryProvider
|
|
94
94
|
? this.getFactoryProviderDependencies(wrapper)
|
|
95
95
|
: this.getClassDependencies(wrapper);
|
|
@@ -131,8 +131,8 @@ class Injector {
|
|
|
131
131
|
getFactoryProviderDependencies(wrapper) {
|
|
132
132
|
var _a, _b;
|
|
133
133
|
const optionalDependenciesIds = [];
|
|
134
|
-
const isOptionalFactoryDep = (item) => !shared_utils_1.isUndefined(item.token) &&
|
|
135
|
-
!shared_utils_1.isUndefined(item.optional);
|
|
134
|
+
const isOptionalFactoryDep = (item) => !(0, shared_utils_1.isUndefined)(item.token) &&
|
|
135
|
+
!(0, shared_utils_1.isUndefined)(item.optional);
|
|
136
136
|
const mapFactoryProviderInjectArray = (item, index) => {
|
|
137
137
|
if (typeof item !== 'object') {
|
|
138
138
|
return item;
|
|
@@ -163,7 +163,7 @@ class Injector {
|
|
|
163
163
|
return Reflect.getMetadata(constants_1.SELF_DECLARED_DEPS_METADATA, type) || [];
|
|
164
164
|
}
|
|
165
165
|
async resolveSingleParam(wrapper, param, dependencyContext, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer, keyOrIndex) {
|
|
166
|
-
if (shared_utils_1.isUndefined(param)) {
|
|
166
|
+
if ((0, shared_utils_1.isUndefined)(param)) {
|
|
167
167
|
this.logger.log('Nest encountered an undefined dependency. This may be due to a circular import or a missing dependency declaration.');
|
|
168
168
|
throw new undefined_dependency_exception_1.UndefinedDependencyException(wrapper.name, dependencyContext, moduleRef);
|
|
169
169
|
}
|
|
@@ -185,10 +185,11 @@ class Injector {
|
|
|
185
185
|
return this.resolveComponentHost(moduleRef, instanceWrapper, contextId, inquirer);
|
|
186
186
|
}
|
|
187
187
|
async resolveComponentHost(moduleRef, instanceWrapper, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
188
|
+
var _a;
|
|
188
189
|
const inquirerId = this.getInquirerId(inquirer);
|
|
189
190
|
const instanceHost = instanceWrapper.getInstanceByContextId(contextId, inquirerId);
|
|
190
191
|
if (!instanceHost.isResolved && !instanceWrapper.forwardRef) {
|
|
191
|
-
await this.loadProvider(instanceWrapper, moduleRef, contextId, inquirer);
|
|
192
|
+
await this.loadProvider(instanceWrapper, (_a = instanceWrapper.host) !== null && _a !== void 0 ? _a : moduleRef, contextId, inquirer);
|
|
192
193
|
}
|
|
193
194
|
else if (!instanceHost.isResolved &&
|
|
194
195
|
instanceWrapper.forwardRef &&
|
|
@@ -226,7 +227,7 @@ class Injector {
|
|
|
226
227
|
}
|
|
227
228
|
async lookupComponentInParentModules(dependencyContext, moduleRef, wrapper, contextId = constants_2.STATIC_CONTEXT, inquirer, keyOrIndex) {
|
|
228
229
|
const instanceWrapper = await this.lookupComponentInImports(moduleRef, dependencyContext.name, wrapper, [], contextId, inquirer, keyOrIndex);
|
|
229
|
-
if (shared_utils_1.isNil(instanceWrapper)) {
|
|
230
|
+
if ((0, shared_utils_1.isNil)(instanceWrapper)) {
|
|
230
231
|
throw new unknown_dependencies_exception_1.UnknownDependenciesException(wrapper.name, dependencyContext, moduleRef);
|
|
231
232
|
}
|
|
232
233
|
return instanceWrapper;
|
|
@@ -268,7 +269,7 @@ class Injector {
|
|
|
268
269
|
return instanceWrapperRef;
|
|
269
270
|
}
|
|
270
271
|
async resolveProperties(wrapper, moduleRef, inject, contextId = constants_2.STATIC_CONTEXT, inquirer, parentInquirer) {
|
|
271
|
-
if (!shared_utils_1.isNil(inject)) {
|
|
272
|
+
if (!(0, shared_utils_1.isNil)(inject)) {
|
|
272
273
|
return [];
|
|
273
274
|
}
|
|
274
275
|
const metadata = wrapper.getPropertiesMetadata();
|
|
@@ -308,11 +309,11 @@ class Injector {
|
|
|
308
309
|
return properties.map((item) => (Object.assign(Object.assign({}, item), { name: item.type, isOptional: optionalKeys.includes(item.key) })));
|
|
309
310
|
}
|
|
310
311
|
applyProperties(instance, properties) {
|
|
311
|
-
if (!shared_utils_1.isObject(instance)) {
|
|
312
|
+
if (!(0, shared_utils_1.isObject)(instance)) {
|
|
312
313
|
return undefined;
|
|
313
314
|
}
|
|
314
|
-
iterare_1.iterate(properties)
|
|
315
|
-
.filter(item => !shared_utils_1.isNil(item.instance))
|
|
315
|
+
(0, iterare_1.iterate)(properties)
|
|
316
|
+
.filter(item => !(0, shared_utils_1.isNil)(item.instance))
|
|
316
317
|
.forEach(item => (instance[item.key] = item.instance));
|
|
317
318
|
}
|
|
318
319
|
async instantiateClass(instances, wrapper, targetMetatype, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
@@ -323,7 +324,7 @@ class Injector {
|
|
|
323
324
|
wrapper.isInRequestScope(contextId, inquirer) ||
|
|
324
325
|
wrapper.isLazyTransient(contextId, inquirer) ||
|
|
325
326
|
wrapper.isExplicitlyRequested(contextId, inquirer);
|
|
326
|
-
if (shared_utils_1.isNil(inject) && isInContext) {
|
|
327
|
+
if ((0, shared_utils_1.isNil)(inject) && isInContext) {
|
|
327
328
|
instanceHost.instance = wrapper.forwardRef
|
|
328
329
|
? Object.assign(instanceHost.instance, new metatype(...instances))
|
|
329
330
|
: new metatype(...instances);
|
|
@@ -385,12 +386,12 @@ class Injector {
|
|
|
385
386
|
return param === inquirer_1.INQUIRER && parentInquirer;
|
|
386
387
|
}
|
|
387
388
|
addDependencyMetadata(keyOrIndex, hostWrapper, instanceWrapper) {
|
|
388
|
-
shared_utils_1.isString(keyOrIndex)
|
|
389
|
+
(0, shared_utils_1.isString)(keyOrIndex)
|
|
389
390
|
? hostWrapper.addPropertiesMetadata(keyOrIndex, instanceWrapper)
|
|
390
391
|
: hostWrapper.addCtorMetadata(keyOrIndex, instanceWrapper);
|
|
391
392
|
}
|
|
392
393
|
getTokenName(token) {
|
|
393
|
-
return shared_utils_1.isFunction(token) ? token.name : token.toString();
|
|
394
|
+
return (0, shared_utils_1.isFunction)(token) ? token.name : token.toString();
|
|
394
395
|
}
|
|
395
396
|
printResolvingDependenciesLog(token, inquirer) {
|
|
396
397
|
var _a, _b, _c;
|