@nestjs/core 9.1.5 → 9.1.6
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/errors/exceptions/index.d.ts +8 -0
- package/errors/exceptions/index.js +11 -0
- package/guards/index.d.ts +3 -0
- package/guards/index.js +6 -0
- package/injector/container.js +7 -9
- package/injector/module-ref.js +3 -4
- package/injector/module.js +4 -6
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +5 -0
- package/middleware/middleware-module.d.ts +1 -1
- package/nest-application-context.js +4 -6
- package/nest-application.d.ts +1 -2
- package/package.json +2 -2
- package/pipes/index.d.ts +3 -0
- package/pipes/index.js +6 -0
- package/router/router-execution-context.d.ts +1 -2
- package/router/router-execution-context.js +6 -6
- package/router/router-explorer.d.ts +1 -1
- package/router/router-explorer.js +2 -2
- package/router/routes-resolver.d.ts +1 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './circular-dependency.exception';
|
|
2
|
+
export * from './runtime.exception';
|
|
3
|
+
export * from './unknown-element.exception';
|
|
4
|
+
export * from './invalid-class-scope.exception';
|
|
5
|
+
export * from './invalid-class.exception';
|
|
6
|
+
export * from './unknown-export.exception';
|
|
7
|
+
export * from './unknown-module.exception';
|
|
8
|
+
export * from './undefined-forwardref.exception';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./circular-dependency.exception"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./runtime.exception"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./unknown-element.exception"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./invalid-class-scope.exception"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./invalid-class.exception"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./unknown-export.exception"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./unknown-module.exception"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./undefined-forwardref.exception"), exports);
|
package/guards/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./guards-consumer"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./guards-context-creator"), exports);
|
package/injector/container.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NestContainer = void 0;
|
|
4
4
|
const constants_1 = require("@nestjs/common/constants");
|
|
5
|
-
const
|
|
6
|
-
const undefined_forwardref_exception_1 = require("../errors/exceptions/undefined-forwardref.exception");
|
|
7
|
-
const unknown_module_exception_1 = require("../errors/exceptions/unknown-module.exception");
|
|
5
|
+
const exceptions_1 = require("../errors/exceptions");
|
|
8
6
|
const request_constants_1 = require("../router/request/request-constants");
|
|
9
7
|
const compiler_1 = require("./compiler");
|
|
10
8
|
const internal_core_module_1 = require("./internal-core-module");
|
|
@@ -43,7 +41,7 @@ class NestContainer {
|
|
|
43
41
|
// In DependenciesScanner#scanForModules we already check for undefined or invalid modules
|
|
44
42
|
// We still need to catch the edge-case of `forwardRef(() => undefined)`
|
|
45
43
|
if (!metatype) {
|
|
46
|
-
throw new
|
|
44
|
+
throw new exceptions_1.UndefinedForwardRefException(scope);
|
|
47
45
|
}
|
|
48
46
|
const { type, dynamicMetadata, token } = await this.moduleCompiler.compile(metatype);
|
|
49
47
|
if (this.modules.has(token)) {
|
|
@@ -105,30 +103,30 @@ class NestContainer {
|
|
|
105
103
|
addProvider(provider, token) {
|
|
106
104
|
const moduleRef = this.modules.get(token);
|
|
107
105
|
if (!provider) {
|
|
108
|
-
throw new
|
|
106
|
+
throw new exceptions_1.CircularDependencyException(moduleRef === null || moduleRef === void 0 ? void 0 : moduleRef.metatype.name);
|
|
109
107
|
}
|
|
110
108
|
if (!moduleRef) {
|
|
111
|
-
throw new
|
|
109
|
+
throw new exceptions_1.UnknownModuleException();
|
|
112
110
|
}
|
|
113
111
|
return moduleRef.addProvider(provider);
|
|
114
112
|
}
|
|
115
113
|
addInjectable(injectable, token, host) {
|
|
116
114
|
if (!this.modules.has(token)) {
|
|
117
|
-
throw new
|
|
115
|
+
throw new exceptions_1.UnknownModuleException();
|
|
118
116
|
}
|
|
119
117
|
const moduleRef = this.modules.get(token);
|
|
120
118
|
moduleRef.addInjectable(injectable, host);
|
|
121
119
|
}
|
|
122
120
|
addExportedProvider(provider, token) {
|
|
123
121
|
if (!this.modules.has(token)) {
|
|
124
|
-
throw new
|
|
122
|
+
throw new exceptions_1.UnknownModuleException();
|
|
125
123
|
}
|
|
126
124
|
const moduleRef = this.modules.get(token);
|
|
127
125
|
moduleRef.addExportedProvider(provider);
|
|
128
126
|
}
|
|
129
127
|
addController(controller, token) {
|
|
130
128
|
if (!this.modules.has(token)) {
|
|
131
|
-
throw new
|
|
129
|
+
throw new exceptions_1.UnknownModuleException();
|
|
132
130
|
}
|
|
133
131
|
const moduleRef = this.modules.get(token);
|
|
134
132
|
moduleRef.addController(controller);
|
package/injector/module-ref.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModuleRef = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const
|
|
6
|
-
const unknown_element_exception_1 = require("../errors/exceptions/unknown-element.exception");
|
|
5
|
+
const exceptions_1 = require("../errors/exceptions");
|
|
7
6
|
const get_class_scope_1 = require("../helpers/get-class-scope");
|
|
8
7
|
const is_durable_1 = require("../helpers/is-durable");
|
|
9
8
|
const injector_1 = require("./injector");
|
|
@@ -39,7 +38,7 @@ class ModuleRef {
|
|
|
39
38
|
const { wrapperRef } = this.instanceLinksHost.get(typeOrToken, moduleId);
|
|
40
39
|
if (wrapperRef.scope === common_1.Scope.REQUEST ||
|
|
41
40
|
wrapperRef.scope === common_1.Scope.TRANSIENT) {
|
|
42
|
-
throw new
|
|
41
|
+
throw new exceptions_1.InvalidClassScopeException(typeOrToken);
|
|
43
42
|
}
|
|
44
43
|
return wrapperRef.instance;
|
|
45
44
|
}
|
|
@@ -55,7 +54,7 @@ class ModuleRef {
|
|
|
55
54
|
const ctorHost = wrapperRef.instance || { constructor: typeOrToken };
|
|
56
55
|
const instance = await this.injector.loadPerContext(ctorHost, wrapperRef.host, collection, contextId, wrapperRef);
|
|
57
56
|
if (!instance) {
|
|
58
|
-
throw new
|
|
57
|
+
throw new exceptions_1.UnknownElementException();
|
|
59
58
|
}
|
|
60
59
|
return instance;
|
|
61
60
|
}
|
package/injector/module.js
CHANGED
|
@@ -5,9 +5,7 @@ const random_string_generator_util_1 = require("@nestjs/common/utils/random-stri
|
|
|
5
5
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
6
|
const iterare_1 = require("iterare");
|
|
7
7
|
const application_config_1 = require("../application-config");
|
|
8
|
-
const
|
|
9
|
-
const runtime_exception_1 = require("../errors/exceptions/runtime.exception");
|
|
10
|
-
const unknown_export_exception_1 = require("../errors/exceptions/unknown-export.exception");
|
|
8
|
+
const exceptions_1 = require("../errors/exceptions");
|
|
11
9
|
const context_id_factory_1 = require("../helpers/context-id-factory");
|
|
12
10
|
const get_class_scope_1 = require("../helpers/get-class-scope");
|
|
13
11
|
const is_durable_1 = require("../helpers/is-durable");
|
|
@@ -75,7 +73,7 @@ class Module {
|
|
|
75
73
|
}
|
|
76
74
|
get instance() {
|
|
77
75
|
if (!this._providers.has(this._metatype)) {
|
|
78
|
-
throw new
|
|
76
|
+
throw new exceptions_1.RuntimeException();
|
|
79
77
|
}
|
|
80
78
|
const module = this._providers.get(this._metatype);
|
|
81
79
|
return module.instance;
|
|
@@ -288,7 +286,7 @@ class Module {
|
|
|
288
286
|
if (!imports.includes(token)) {
|
|
289
287
|
const { name } = this.metatype;
|
|
290
288
|
const providerName = (0, shared_utils_1.isFunction)(token) ? token.name : token;
|
|
291
|
-
throw new
|
|
289
|
+
throw new exceptions_1.UnknownExportException(providerName, name);
|
|
292
290
|
}
|
|
293
291
|
return token;
|
|
294
292
|
}
|
|
@@ -355,7 +353,7 @@ class Module {
|
|
|
355
353
|
}
|
|
356
354
|
async create(type) {
|
|
357
355
|
if (!(type && (0, shared_utils_1.isFunction)(type) && type.prototype)) {
|
|
358
|
-
throw new
|
|
356
|
+
throw new exceptions_1.InvalidClassException(type);
|
|
359
357
|
}
|
|
360
358
|
return this.instantiateClass(type, self);
|
|
361
359
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpServer } from '@nestjs/common';
|
|
2
|
-
import { MiddlewareConfiguration, RouteInfo } from '@nestjs/common/interfaces/middleware
|
|
2
|
+
import { MiddlewareConfiguration, RouteInfo } from '@nestjs/common/interfaces/middleware';
|
|
3
3
|
import { ApplicationConfig } from '../application-config';
|
|
4
4
|
import { NestContainer } from '../injector/container';
|
|
5
5
|
import { Injector } from '../injector/injector';
|
|
@@ -6,9 +6,7 @@ const interfaces_1 = require("@nestjs/common/interfaces");
|
|
|
6
6
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
7
|
const iterare_1 = require("iterare");
|
|
8
8
|
const constants_1 = require("./constants");
|
|
9
|
-
const
|
|
10
|
-
const unknown_element_exception_1 = require("./errors/exceptions/unknown-element.exception");
|
|
11
|
-
const unknown_module_exception_1 = require("./errors/exceptions/unknown-module.exception");
|
|
9
|
+
const exceptions_1 = require("./errors/exceptions");
|
|
12
10
|
const context_id_factory_1 = require("./helpers/context-id-factory");
|
|
13
11
|
const hooks_1 = require("./hooks");
|
|
14
12
|
const compiler_1 = require("./injector/compiler");
|
|
@@ -47,7 +45,7 @@ class NestApplicationContext {
|
|
|
47
45
|
const token = moduleTokenFactory.create(type, dynamicMetadata);
|
|
48
46
|
const selectedModule = modulesContainer.get(token);
|
|
49
47
|
if (!selectedModule) {
|
|
50
|
-
throw new
|
|
48
|
+
throw new exceptions_1.UnknownModuleException();
|
|
51
49
|
}
|
|
52
50
|
return new NestApplicationContext(this.container, scope, selectedModule);
|
|
53
51
|
}
|
|
@@ -223,7 +221,7 @@ class NestApplicationContext {
|
|
|
223
221
|
const { wrapperRef } = this.instanceLinksHost.get(typeOrToken, moduleId);
|
|
224
222
|
if (wrapperRef.scope === interfaces_1.Scope.REQUEST ||
|
|
225
223
|
wrapperRef.scope === interfaces_1.Scope.TRANSIENT) {
|
|
226
|
-
throw new
|
|
224
|
+
throw new exceptions_1.InvalidClassScopeException(typeOrToken);
|
|
227
225
|
}
|
|
228
226
|
return wrapperRef.instance;
|
|
229
227
|
}
|
|
@@ -239,7 +237,7 @@ class NestApplicationContext {
|
|
|
239
237
|
const ctorHost = wrapperRef.instance || { constructor: typeOrToken };
|
|
240
238
|
const instance = await this.injector.loadPerContext(ctorHost, wrapperRef.host, collection, contextId, wrapperRef);
|
|
241
239
|
if (!instance) {
|
|
242
|
-
throw new
|
|
240
|
+
throw new exceptions_1.UnknownElementException();
|
|
243
241
|
}
|
|
244
242
|
return instance;
|
|
245
243
|
}
|
package/nest-application.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CanActivate, ExceptionFilter, HttpServer, INestApplication, INestMicroservice, NestHybridApplicationOptions, NestInterceptor, PipeTransform, VersioningOptions, WebSocketAdapter } from '@nestjs/common';
|
|
2
|
+
import { GlobalPrefixOptions, NestApplicationOptions } from '@nestjs/common/interfaces';
|
|
2
3
|
import { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface';
|
|
3
|
-
import { GlobalPrefixOptions } from '@nestjs/common/interfaces/global-prefix-options.interface';
|
|
4
|
-
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
|
5
4
|
import { AbstractHttpAdapter } from './adapters';
|
|
6
5
|
import { ApplicationConfig } from './application-config';
|
|
7
6
|
import { NestContainer } from './injector/container';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.6",
|
|
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
|
"uuid": "9.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "9.1.
|
|
39
|
+
"@nestjs/common": "9.1.6"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^9.0.0",
|
package/pipes/index.d.ts
ADDED
package/pipes/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./params-token-factory"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./pipes-consumer"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./pipes-context-creator"), exports);
|
|
@@ -2,8 +2,7 @@ import { CanActivate, HttpServer, ParamData, PipeTransform, RequestMethod } from
|
|
|
2
2
|
import { RouteParamMetadata } from '@nestjs/common/decorators';
|
|
3
3
|
import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
|
|
4
4
|
import { ContextType, Controller } from '@nestjs/common/interfaces';
|
|
5
|
-
import { GuardsConsumer } from '../guards
|
|
6
|
-
import { GuardsContextCreator } from '../guards/guards-context-creator';
|
|
5
|
+
import { GuardsConsumer, GuardsContextCreator } from '../guards';
|
|
7
6
|
import { ExecutionContextHost } from '../helpers/execution-context-host';
|
|
8
7
|
import { HandleResponseFn, HandlerMetadata } from '../helpers/handler-metadata-storage';
|
|
9
8
|
import { InterceptorsConsumer } from '../interceptors/interceptors-consumer';
|
|
@@ -5,10 +5,10 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const constants_1 = require("@nestjs/common/constants");
|
|
6
6
|
const route_paramtypes_enum_1 = require("@nestjs/common/enums/route-paramtypes.enum");
|
|
7
7
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
8
|
-
const
|
|
8
|
+
const guards_1 = require("../guards");
|
|
9
9
|
const context_utils_1 = require("../helpers/context-utils");
|
|
10
10
|
const handler_metadata_storage_1 = require("../helpers/handler-metadata-storage");
|
|
11
|
-
const
|
|
11
|
+
const constants_2 = require("../injector/constants");
|
|
12
12
|
const router_response_controller_1 = require("./router-response-controller");
|
|
13
13
|
class RouterExecutionContext {
|
|
14
14
|
constructor(paramsFactory, pipesContextCreator, pipesConsumer, guardsContextCreator, guardsConsumer, interceptorsContextCreator, interceptorsConsumer, applicationRef) {
|
|
@@ -24,7 +24,7 @@ class RouterExecutionContext {
|
|
|
24
24
|
this.contextUtils = new context_utils_1.ContextUtils();
|
|
25
25
|
this.responseController = new router_response_controller_1.RouterResponseController(applicationRef);
|
|
26
26
|
}
|
|
27
|
-
create(instance, callback, methodName, moduleKey, requestMethod, contextId =
|
|
27
|
+
create(instance, callback, methodName, moduleKey, requestMethod, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
|
|
28
28
|
const contextType = 'http';
|
|
29
29
|
const { argsLength, fnHandleResponse, paramtypes, getParamsMetadata, httpStatusCode, responseHeaders, hasCustomHeaders, } = this.getMetadata(instance, callback, methodName, moduleKey, requestMethod, contextType);
|
|
30
30
|
const paramsOptions = this.contextUtils.mergeParamsMetatypes(getParamsMetadata(moduleKey, contextId, inquirerId), paramtypes);
|
|
@@ -57,7 +57,7 @@ class RouterExecutionContext {
|
|
|
57
57
|
const argsLength = this.contextUtils.getArgumentsLength(keys, metadata);
|
|
58
58
|
const paramtypes = this.contextUtils.reflectCallbackParamtypes(instance, methodName);
|
|
59
59
|
const contextFactory = this.contextUtils.getContextFactory(contextType, instance, callback);
|
|
60
|
-
const getParamsMetadata = (moduleKey, contextId =
|
|
60
|
+
const getParamsMetadata = (moduleKey, contextId = constants_2.STATIC_CONTEXT, inquirerId) => this.exchangeKeysForValues(keys, metadata, moduleKey, contextId, inquirerId, contextFactory);
|
|
61
61
|
const paramsMetadata = getParamsMetadata(moduleKey);
|
|
62
62
|
const isResponseHandled = this.isResponseHandled(instance, methodName, paramsMetadata);
|
|
63
63
|
const httpRedirectResponse = this.reflectRedirect(callback);
|
|
@@ -95,7 +95,7 @@ class RouterExecutionContext {
|
|
|
95
95
|
reflectSse(callback) {
|
|
96
96
|
return Reflect.getMetadata(constants_1.SSE_METADATA, callback);
|
|
97
97
|
}
|
|
98
|
-
exchangeKeysForValues(keys, metadata, moduleContext, contextId =
|
|
98
|
+
exchangeKeysForValues(keys, metadata, moduleContext, contextId = constants_2.STATIC_CONTEXT, inquirerId, contextFactory) {
|
|
99
99
|
this.pipesContextCreator.setModuleContext(moduleContext);
|
|
100
100
|
return keys.map(key => {
|
|
101
101
|
const { index, data, pipes: pipesCollection } = metadata[key];
|
|
@@ -133,7 +133,7 @@ class RouterExecutionContext {
|
|
|
133
133
|
const canActivateFn = async (args) => {
|
|
134
134
|
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback, contextType);
|
|
135
135
|
if (!canActivate) {
|
|
136
|
-
throw new common_1.ForbiddenException(
|
|
136
|
+
throw new common_1.ForbiddenException(guards_1.FORBIDDEN_MESSAGE);
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
return guards.length ? canActivateFn : null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpServer } from '@nestjs/common';
|
|
2
|
-
import { RequestMethod } from '@nestjs/common/enums
|
|
2
|
+
import { RequestMethod } from '@nestjs/common/enums';
|
|
3
3
|
import { Controller } from '@nestjs/common/interfaces/controllers/controller.interface';
|
|
4
4
|
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
5
5
|
import { VersionValue } from '@nestjs/common/interfaces/version-options.interface';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RouterExplorer = void 0;
|
|
4
4
|
const constants_1 = require("@nestjs/common/constants");
|
|
5
|
-
const
|
|
5
|
+
const enums_1 = require("@nestjs/common/enums");
|
|
6
6
|
const exceptions_1 = require("@nestjs/common/exceptions");
|
|
7
7
|
const logger_service_1 = require("@nestjs/common/services/logger.service");
|
|
8
8
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
@@ -109,7 +109,7 @@ class RouterExplorer {
|
|
|
109
109
|
let routeHandler = this.applyHostFilter(host, proxy);
|
|
110
110
|
paths.forEach(path => {
|
|
111
111
|
if (isVersioned &&
|
|
112
|
-
routePathMetadata.versioningOptions.type !==
|
|
112
|
+
routePathMetadata.versioningOptions.type !== enums_1.VersioningType.URI) {
|
|
113
113
|
// All versioning (except for URI Versioning) is done via the "Version Filter"
|
|
114
114
|
routeHandler = this.applyVersionFilter(router, routePathMetadata, routeHandler);
|
|
115
115
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { HttpServer } from '@nestjs/common/interfaces';
|
|
2
|
-
import { Controller } from '@nestjs/common/interfaces/controllers/controller.interface';
|
|
1
|
+
import { HttpServer, Controller } from '@nestjs/common/interfaces';
|
|
3
2
|
import { ApplicationConfig } from '../application-config';
|
|
4
3
|
import { NestContainer } from '../injector/container';
|
|
5
4
|
import { Injector } from '../injector/injector';
|