@nestjs/core 11.1.13 → 11.1.14
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/package.json +3 -3
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +0 -3
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +0 -30
- package/hooks/utils/get-sorted-hierarchy-levels.d.ts +0 -1
- package/hooks/utils/get-sorted-hierarchy-levels.js +0 -10
- package/injector/module-token-factory.d.ts +0 -14
- package/injector/module-token-factory.js +0 -84
- package/repl/native-functions/get-relp-fn.d.ts +0 -7
- package/repl/native-functions/get-relp-fn.js +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.14",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"uid": "2.0.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@nestjs/common": "11.1.
|
|
42
|
+
"@nestjs/common": "11.1.14"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@nestjs/common": "^11.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"optional": true
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "5d31df7eb62d89952d827eadc19123fb441f541e"
|
|
64
64
|
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@nestjs/common';
|
|
2
|
-
import { InstanceWrapper } from '../../injector/instance-wrapper';
|
|
3
|
-
export declare function getInstancesGroupedByHierarchyLevel(...collections: Array<Map<InjectionToken, InstanceWrapper> | Array<[InjectionToken, InstanceWrapper]>>): Map<number, unknown[]>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInstancesGroupedByHierarchyLevel = getInstancesGroupedByHierarchyLevel;
|
|
4
|
-
function getInstancesGroupedByHierarchyLevel(...collections) {
|
|
5
|
-
const groupedByHierarchyLevel = new Map();
|
|
6
|
-
for (const collection of collections) {
|
|
7
|
-
for (const [_, wrapper] of collection) {
|
|
8
|
-
if (!wrapper.isDependencyTreeStatic()) {
|
|
9
|
-
continue;
|
|
10
|
-
}
|
|
11
|
-
const level = wrapper.hierarchyLevel;
|
|
12
|
-
if (!groupedByHierarchyLevel.has(level)) {
|
|
13
|
-
groupedByHierarchyLevel.set(level, []);
|
|
14
|
-
}
|
|
15
|
-
const byHierarchyLevelGroup = groupedByHierarchyLevel.get(level);
|
|
16
|
-
if (wrapper.isTransient) {
|
|
17
|
-
const staticTransientInstances = wrapper
|
|
18
|
-
.getStaticTransientInstances()
|
|
19
|
-
.filter(i => !!i)
|
|
20
|
-
.map(i => i.instance);
|
|
21
|
-
byHierarchyLevelGroup.push(...staticTransientInstances);
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (wrapper.instance) {
|
|
25
|
-
byHierarchyLevelGroup.push(wrapper.instance);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return groupedByHierarchyLevel;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getSortedHierarchyLevels(groups: Map<number, unknown[]>, order?: 'ASC' | 'DESC'): number[];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSortedHierarchyLevels = getSortedHierarchyLevels;
|
|
4
|
-
function getSortedHierarchyLevels(groups, order = 'ASC') {
|
|
5
|
-
const comparator = order === 'ASC'
|
|
6
|
-
? (a, b) => a - b
|
|
7
|
-
: (a, b) => b - a;
|
|
8
|
-
const levels = Array.from(groups.keys()).sort(comparator);
|
|
9
|
-
return levels;
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
3
|
-
export declare class ModuleTokenFactory {
|
|
4
|
-
private readonly moduleTokenCache;
|
|
5
|
-
private readonly moduleIdsCache;
|
|
6
|
-
private readonly logger;
|
|
7
|
-
create(metatype: Type<unknown>, dynamicModuleMetadata?: Partial<DynamicModule> | undefined): string;
|
|
8
|
-
getStaticModuleToken(moduleId: string, moduleName: string): string;
|
|
9
|
-
getStringifiedOpaqueToken(opaqueToken: object | undefined): string;
|
|
10
|
-
getModuleId(metatype: Type<unknown>): string;
|
|
11
|
-
getModuleName(metatype: Type<any>): string;
|
|
12
|
-
private hashString;
|
|
13
|
-
private replacer;
|
|
14
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModuleTokenFactory = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
|
|
6
|
-
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
|
-
const crypto_1 = require("crypto");
|
|
8
|
-
const fast_safe_stringify_1 = require("fast-safe-stringify");
|
|
9
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
10
|
-
const CLASS_STR = 'class ';
|
|
11
|
-
const CLASS_STR_LEN = CLASS_STR.length;
|
|
12
|
-
class ModuleTokenFactory {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.moduleTokenCache = new Map();
|
|
15
|
-
this.moduleIdsCache = new WeakMap();
|
|
16
|
-
this.logger = new common_1.Logger(ModuleTokenFactory.name, {
|
|
17
|
-
timestamp: true,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
create(metatype, dynamicModuleMetadata) {
|
|
21
|
-
const moduleId = this.getModuleId(metatype);
|
|
22
|
-
if (!dynamicModuleMetadata) {
|
|
23
|
-
return this.getStaticModuleToken(moduleId, this.getModuleName(metatype));
|
|
24
|
-
}
|
|
25
|
-
const opaqueToken = {
|
|
26
|
-
id: moduleId,
|
|
27
|
-
module: this.getModuleName(metatype),
|
|
28
|
-
dynamic: dynamicModuleMetadata,
|
|
29
|
-
};
|
|
30
|
-
const start = perf_hooks_1.performance.now();
|
|
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
|
-
}
|
|
37
|
-
return this.hashString(opaqueTokenString);
|
|
38
|
-
}
|
|
39
|
-
getStaticModuleToken(moduleId, moduleName) {
|
|
40
|
-
const key = `${moduleId}_${moduleName}`;
|
|
41
|
-
if (this.moduleTokenCache.has(key)) {
|
|
42
|
-
return this.moduleTokenCache.get(key);
|
|
43
|
-
}
|
|
44
|
-
const hash = this.hashString(key);
|
|
45
|
-
this.moduleTokenCache.set(key, hash);
|
|
46
|
-
return hash;
|
|
47
|
-
}
|
|
48
|
-
getStringifiedOpaqueToken(opaqueToken) {
|
|
49
|
-
// Uses safeStringify instead of JSON.stringify to support circular dynamic modules
|
|
50
|
-
// The replacer function is also required in order to obtain real class names
|
|
51
|
-
// instead of the unified "Function" key
|
|
52
|
-
return opaqueToken ? (0, fast_safe_stringify_1.default)(opaqueToken, this.replacer) : '';
|
|
53
|
-
}
|
|
54
|
-
getModuleId(metatype) {
|
|
55
|
-
let moduleId = this.moduleIdsCache.get(metatype);
|
|
56
|
-
if (moduleId) {
|
|
57
|
-
return moduleId;
|
|
58
|
-
}
|
|
59
|
-
moduleId = (0, random_string_generator_util_1.randomStringGenerator)();
|
|
60
|
-
this.moduleIdsCache.set(metatype, moduleId);
|
|
61
|
-
return moduleId;
|
|
62
|
-
}
|
|
63
|
-
getModuleName(metatype) {
|
|
64
|
-
return metatype.name;
|
|
65
|
-
}
|
|
66
|
-
hashString(value) {
|
|
67
|
-
return (0, crypto_1.createHash)('sha256').update(value).digest('hex');
|
|
68
|
-
}
|
|
69
|
-
replacer(key, value) {
|
|
70
|
-
if ((0, shared_utils_1.isFunction)(value)) {
|
|
71
|
-
const funcAsString = value.toString();
|
|
72
|
-
const isClass = funcAsString.slice(0, CLASS_STR_LEN) === CLASS_STR;
|
|
73
|
-
if (isClass) {
|
|
74
|
-
return value.name;
|
|
75
|
-
}
|
|
76
|
-
return funcAsString;
|
|
77
|
-
}
|
|
78
|
-
if ((0, shared_utils_1.isSymbol)(value)) {
|
|
79
|
-
return value.toString();
|
|
80
|
-
}
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.ModuleTokenFactory = ModuleTokenFactory;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Type } from '@nestjs/common';
|
|
2
|
-
import { ReplFunction } from '../repl-function';
|
|
3
|
-
import type { ReplFnDefinition } from '../repl.interfaces';
|
|
4
|
-
export declare class GetReplFn extends ReplFunction {
|
|
5
|
-
fnDefinition: ReplFnDefinition;
|
|
6
|
-
action(token: string | symbol | Function | Type<any>): any;
|
|
7
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GetReplFn = void 0;
|
|
4
|
-
const repl_function_1 = require("../repl-function");
|
|
5
|
-
class GetReplFn extends repl_function_1.ReplFunction {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.fnDefinition = {
|
|
9
|
-
name: 'get',
|
|
10
|
-
signature: '(token: InjectionToken) => any',
|
|
11
|
-
description: 'Retrieves an instance of either injectable or controller, otherwise, throws exception.',
|
|
12
|
-
aliases: ['$'],
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
action(token) {
|
|
16
|
-
return this.ctx.app.get(token);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.GetReplFn = GetReplFn;
|