@nestjs/core 10.4.8 → 10.4.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/injector/injector.js
CHANGED
|
@@ -153,13 +153,20 @@ class Injector {
|
|
|
153
153
|
}
|
|
154
154
|
getFactoryProviderDependencies(wrapper) {
|
|
155
155
|
const optionalDependenciesIds = [];
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Same as the internal utility function `isOptionalFactoryDependency` from `@nestjs/common`.
|
|
158
|
+
* We are duplicating it here because that one is not supposed to be exported.
|
|
159
|
+
*/
|
|
160
|
+
function isOptionalFactoryDependency(value) {
|
|
161
|
+
return (!(0, shared_utils_1.isUndefined)(value.token) &&
|
|
162
|
+
!(0, shared_utils_1.isUndefined)(value.optional) &&
|
|
163
|
+
!value.prototype);
|
|
164
|
+
}
|
|
158
165
|
const mapFactoryProviderInjectArray = (item, index) => {
|
|
159
166
|
if (typeof item !== 'object') {
|
|
160
167
|
return item;
|
|
161
168
|
}
|
|
162
|
-
if (
|
|
169
|
+
if (isOptionalFactoryDependency(item)) {
|
|
163
170
|
if (item.optional) {
|
|
164
171
|
optionalDependenciesIds.push(index);
|
|
165
172
|
}
|
package/injector/module.d.ts
CHANGED
package/injector/module.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Module = void 0;
|
|
4
4
|
const constants_1 = require("@nestjs/common/constants");
|
|
5
|
+
const interfaces_1 = require("@nestjs/common/interfaces");
|
|
5
6
|
const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
|
|
6
7
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
8
|
const iterare_1 = require("iterare");
|
|
@@ -159,6 +160,10 @@ class Module {
|
|
|
159
160
|
}
|
|
160
161
|
return this.addCustomProvider(provider, this._providers, enhancerSubtype);
|
|
161
162
|
}
|
|
163
|
+
const isAlreadyDeclared = this._providers.has(provider);
|
|
164
|
+
if (this.isTransientProvider(provider) && isAlreadyDeclared) {
|
|
165
|
+
return provider;
|
|
166
|
+
}
|
|
162
167
|
this._providers.set(provider, new instance_wrapper_1.InstanceWrapper({
|
|
163
168
|
token: provider,
|
|
164
169
|
name: provider.name,
|
|
@@ -416,5 +421,8 @@ class Module {
|
|
|
416
421
|
const key = this.name?.toString() ?? this.token?.toString();
|
|
417
422
|
return key ? uuid_factory_1.UuidFactory.get(`${prefix}_${key}`) : (0, random_string_generator_util_1.randomStringGenerator)();
|
|
418
423
|
}
|
|
424
|
+
isTransientProvider(provider) {
|
|
425
|
+
return (0, get_class_scope_1.getClassScope)(provider) === interfaces_1.Scope.TRANSIENT;
|
|
426
|
+
}
|
|
419
427
|
}
|
|
420
428
|
exports.Module = Module;
|
|
@@ -182,7 +182,9 @@ class MiddlewareModule {
|
|
|
182
182
|
writable: false,
|
|
183
183
|
configurable: false,
|
|
184
184
|
});
|
|
185
|
-
const requestProviderValue = isTreeDurable
|
|
185
|
+
const requestProviderValue = isTreeDurable
|
|
186
|
+
? contextId.payload
|
|
187
|
+
: Object.assign(request, contextId.payload);
|
|
186
188
|
this.container.registerRequestProvider(requestProviderValue, contextId);
|
|
187
189
|
}
|
|
188
190
|
return contextId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.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.4.
|
|
39
|
+
"@nestjs/common": "10.4.9"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^10.0.0",
|
|
@@ -196,7 +196,9 @@ class RouterExplorer {
|
|
|
196
196
|
writable: false,
|
|
197
197
|
configurable: false,
|
|
198
198
|
});
|
|
199
|
-
const requestProviderValue = isTreeDurable
|
|
199
|
+
const requestProviderValue = isTreeDurable
|
|
200
|
+
? contextId.payload
|
|
201
|
+
: Object.assign(request, contextId.payload);
|
|
200
202
|
this.container.registerRequestProvider(requestProviderValue, contextId);
|
|
201
203
|
}
|
|
202
204
|
return contextId;
|