@nestjs/core 9.1.4 → 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.
@@ -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);
@@ -0,0 +1,3 @@
1
+ export * from './constants';
2
+ export * from './guards-consumer';
3
+ export * from './guards-context-creator';
@@ -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);
@@ -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 circular_dependency_exception_1 = require("../errors/exceptions/circular-dependency.exception");
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 undefined_forwardref_exception_1.UndefinedForwardRefException(scope);
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 circular_dependency_exception_1.CircularDependencyException(moduleRef === null || moduleRef === void 0 ? void 0 : moduleRef.metatype.name);
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 unknown_module_exception_1.UnknownModuleException();
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 unknown_module_exception_1.UnknownModuleException();
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 unknown_module_exception_1.UnknownModuleException();
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 unknown_module_exception_1.UnknownModuleException();
129
+ throw new exceptions_1.UnknownModuleException();
132
130
  }
133
131
  const moduleRef = this.modules.get(token);
134
132
  moduleRef.addController(controller);
@@ -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 invalid_class_scope_exception_1 = require("../errors/exceptions/invalid-class-scope.exception");
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 invalid_class_scope_exception_1.InvalidClassScopeException(typeOrToken);
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 unknown_element_exception_1.UnknownElementException();
57
+ throw new exceptions_1.UnknownElementException();
59
58
  }
60
59
  return instance;
61
60
  }
@@ -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 invalid_class_exception_1 = require("../errors/exceptions/invalid-class.exception");
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 runtime_exception_1.RuntimeException();
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 unknown_export_exception_1.UnknownExportException(providerName, name);
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 invalid_class_exception_1.InvalidClassException(type);
356
+ throw new exceptions_1.InvalidClassException(type);
359
357
  }
360
358
  return this.instantiateClass(type, self);
361
359
  }
@@ -0,0 +1,2 @@
1
+ export * from './interceptors-consumer';
2
+ export * from './interceptors-context-creator';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./interceptors-consumer"), exports);
5
+ tslib_1.__exportStar(require("./interceptors-context-creator"), exports);
@@ -1,5 +1,5 @@
1
1
  import { HttpServer } from '@nestjs/common';
2
- import { MiddlewareConfiguration, RouteInfo } from '@nestjs/common/interfaces/middleware/middleware-configuration.interface';
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 invalid_class_scope_exception_1 = require("./errors/exceptions/invalid-class-scope.exception");
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 unknown_module_exception_1.UnknownModuleException();
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 invalid_class_scope_exception_1.InvalidClassScopeException(typeOrToken);
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 unknown_element_exception_1.UnknownElementException();
240
+ throw new exceptions_1.UnknownElementException();
243
241
  }
244
242
  return instance;
245
243
  }
@@ -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';
@@ -188,6 +188,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
188
188
  if (!this.isListening) {
189
189
  this.logger.error(constants_1.MESSAGES.CALL_LISTEN_FIRST);
190
190
  reject(constants_1.MESSAGES.CALL_LISTEN_FIRST);
191
+ return;
191
192
  }
192
193
  const address = this.httpServer.address();
193
194
  resolve(this.formatAddress(address));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "9.1.4",
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.4"
39
+ "@nestjs/common": "9.1.6"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@nestjs/common": "^9.0.0",
@@ -0,0 +1,3 @@
1
+ export * from './params-token-factory';
2
+ export * from './pipes-consumer';
3
+ export * from './pipes-context-creator';
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/guards-consumer';
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 constants_2 = require("../guards/constants");
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 constants_3 = require("../injector/constants");
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 = constants_3.STATIC_CONTEXT, inquirerId) {
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 = constants_3.STATIC_CONTEXT, inquirerId) => this.exchangeKeysForValues(keys, metadata, moduleKey, contextId, inquirerId, contextFactory);
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 = constants_3.STATIC_CONTEXT, inquirerId, contextFactory) {
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(constants_2.FORBIDDEN_MESSAGE);
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/request-method.enum';
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 version_type_enum_1 = require("@nestjs/common/enums/version-type.enum");
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 !== version_type_enum_1.VersioningType.URI) {
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';