@nestjs/core 10.2.7 → 10.2.9
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/discoverable-meta-host-collection.js +2 -2
- package/errors/messages.js +15 -8
- package/injector/module-token-factory.d.ts +1 -0
- package/injector/module-token-factory.js +11 -0
- package/middleware/routes-mapper.js +1 -2
- package/package.json +2 -2
- package/router/interfaces/routes.interface.d.ts +1 -1
|
@@ -43,11 +43,11 @@ class DiscoverableMetaHostCollection {
|
|
|
43
43
|
}
|
|
44
44
|
static getProvidersByMetaKey(hostContainerRef, metaKey) {
|
|
45
45
|
const wrappersByMetaKey = this.providersByMetaKey.get(hostContainerRef);
|
|
46
|
-
return wrappersByMetaKey
|
|
46
|
+
return wrappersByMetaKey?.get(metaKey) ?? new Set();
|
|
47
47
|
}
|
|
48
48
|
static getControllersByMetaKey(hostContainerRef, metaKey) {
|
|
49
49
|
const wrappersByMetaKey = this.controllersByMetaKey.get(hostContainerRef);
|
|
50
|
-
return wrappersByMetaKey
|
|
50
|
+
return wrappersByMetaKey?.get(metaKey) ?? new Set();
|
|
51
51
|
}
|
|
52
52
|
static inspectInstanceWrapper(hostContainerRef, instanceWrapper, wrapperByMetaKeyMap) {
|
|
53
53
|
const metaKey = DiscoverableMetaHostCollection.getMetaKeyByInstanceWrapper(instanceWrapper);
|
package/errors/messages.js
CHANGED
|
@@ -16,20 +16,27 @@ const getInstanceName = (instance) => {
|
|
|
16
16
|
return instance?.name;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Returns the name of the dependency
|
|
19
|
+
* Returns the name of the dependency.
|
|
20
20
|
* Tries to get the class name, otherwise the string value
|
|
21
|
-
* (= injection token). As fallback
|
|
21
|
+
* (= injection token). As fallback to any falsy value for `dependency`, it
|
|
22
|
+
* returns `fallbackValue`
|
|
22
23
|
* @param dependency The name of the dependency to be displayed
|
|
24
|
+
* @param fallbackValue The fallback value if the dependency is falsy
|
|
25
|
+
* @param disambiguated Whether dependency's name is disambiguated with double quotes
|
|
23
26
|
*/
|
|
24
|
-
const getDependencyName = (dependency) =>
|
|
27
|
+
const getDependencyName = (dependency, fallbackValue, disambiguated = true) =>
|
|
25
28
|
// use class name
|
|
26
29
|
getInstanceName(dependency) ||
|
|
27
30
|
// use injection token (symbol)
|
|
28
31
|
((0, shared_utils_1.isSymbol)(dependency) && dependency.toString()) ||
|
|
29
32
|
// use string directly
|
|
30
|
-
dependency
|
|
33
|
+
(dependency
|
|
34
|
+
? disambiguated
|
|
35
|
+
? `"${dependency}"`
|
|
36
|
+
: dependency
|
|
37
|
+
: undefined) ||
|
|
31
38
|
// otherwise
|
|
32
|
-
|
|
39
|
+
fallbackValue;
|
|
33
40
|
/**
|
|
34
41
|
* Returns the name of the module
|
|
35
42
|
* Tries to get the class name. As fallback it returns 'current'.
|
|
@@ -38,9 +45,9 @@ getInstanceName(dependency) ||
|
|
|
38
45
|
const getModuleName = (module) => (module && getInstanceName(module.metatype)) || 'current';
|
|
39
46
|
const stringifyScope = (scope) => (scope || []).map(getInstanceName).join(' -> ');
|
|
40
47
|
const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, module) => {
|
|
41
|
-
const { index, name
|
|
48
|
+
const { index, name, dependencies, key } = unknownDependencyContext;
|
|
42
49
|
const moduleName = getModuleName(module);
|
|
43
|
-
const dependencyName = getDependencyName(name);
|
|
50
|
+
const dependencyName = getDependencyName(name, 'dependency');
|
|
44
51
|
const potentialSolutions =
|
|
45
52
|
// If module's name is well defined
|
|
46
53
|
moduleName !== 'current'
|
|
@@ -66,7 +73,7 @@ Potential solutions:
|
|
|
66
73
|
message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
|
|
67
74
|
return message;
|
|
68
75
|
}
|
|
69
|
-
const dependenciesName = (dependencies || []).map(getDependencyName);
|
|
76
|
+
const dependenciesName = (dependencies || []).map(dependencyName => getDependencyName(dependencyName, '+', false));
|
|
70
77
|
dependenciesName[index] = '?';
|
|
71
78
|
message += ` (`;
|
|
72
79
|
message += dependenciesName.join(', ');
|
|
@@ -3,6 +3,7 @@ import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
|
3
3
|
export declare class ModuleTokenFactory {
|
|
4
4
|
private readonly moduleTokenCache;
|
|
5
5
|
private readonly moduleIdsCache;
|
|
6
|
+
private readonly logger;
|
|
6
7
|
create(metatype: Type<unknown>, dynamicModuleMetadata?: Partial<DynamicModule> | undefined): string;
|
|
7
8
|
getStaticModuleToken(moduleId: string, moduleName: string): string;
|
|
8
9
|
getStringifiedOpaqueToken(opaqueToken: object | undefined): string;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModuleTokenFactory = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
4
5
|
const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
|
|
5
6
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
7
|
const crypto_1 = require("crypto");
|
|
7
8
|
const fast_safe_stringify_1 = require("fast-safe-stringify");
|
|
9
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
8
10
|
const CLASS_STR = 'class ';
|
|
9
11
|
const CLASS_STR_LEN = CLASS_STR.length;
|
|
10
12
|
class ModuleTokenFactory {
|
|
11
13
|
constructor() {
|
|
12
14
|
this.moduleTokenCache = new Map();
|
|
13
15
|
this.moduleIdsCache = new WeakMap();
|
|
16
|
+
this.logger = new common_1.Logger(ModuleTokenFactory.name, {
|
|
17
|
+
timestamp: true,
|
|
18
|
+
});
|
|
14
19
|
}
|
|
15
20
|
create(metatype, dynamicModuleMetadata) {
|
|
16
21
|
const moduleId = this.getModuleId(metatype);
|
|
@@ -22,7 +27,13 @@ class ModuleTokenFactory {
|
|
|
22
27
|
module: this.getModuleName(metatype),
|
|
23
28
|
dynamic: dynamicModuleMetadata,
|
|
24
29
|
};
|
|
30
|
+
const start = perf_hooks_1.performance.now();
|
|
25
31
|
const opaqueTokenString = this.getStringifiedOpaqueToken(opaqueToken);
|
|
32
|
+
const timeSpentInMs = perf_hooks_1.performance.now() - start;
|
|
33
|
+
if (timeSpentInMs > 10) {
|
|
34
|
+
const formattedTimeSpent = timeSpentInMs.toFixed(2);
|
|
35
|
+
this.logger.warn(`The module "${opaqueToken.module}" is taking ${formattedTimeSpent}ms to serialize, this may be caused by larger objects statically assigned to the module. More details: https://github.com/nestjs/nest/issues/12738`);
|
|
36
|
+
}
|
|
26
37
|
return this.hashString(opaqueTokenString);
|
|
27
38
|
}
|
|
28
39
|
getStaticModuleToken(moduleId, moduleName) {
|
|
@@ -50,8 +50,7 @@ class RoutesMapper {
|
|
|
50
50
|
const modulePath = this.getModulePath(moduleRef?.metatype);
|
|
51
51
|
const concatPaths = (acc, currentValue) => acc.concat(currentValue);
|
|
52
52
|
const toUndefinedIfNeural = (version) => version === interfaces_1.VERSION_NEUTRAL ? undefined : version;
|
|
53
|
-
const toRouteInfo = (item, prefix) => item.path
|
|
54
|
-
?.flatMap(p => {
|
|
53
|
+
const toRouteInfo = (item, prefix) => item.path?.flatMap(p => {
|
|
55
54
|
let endpointPath = modulePath ?? '';
|
|
56
55
|
endpointPath += this.normalizeGlobalPath(prefix) + (0, shared_utils_1.addLeadingSlash)(p);
|
|
57
56
|
const routeInfo = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.9",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"uid": "2.0.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "10.2.
|
|
39
|
+
"@nestjs/common": "10.2.9"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^10.0.0",
|