Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@nestjs/core

Package Overview
Dependencies
Maintainers
1
Versions
447
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/core - npm Package Compare versions

Comparing version
11.1.21
to
11.1.22
+1
-1
errors/exceptions/invalid-class-module.exception.d.ts
import { RuntimeException } from './runtime.exception';
export declare class InvalidClassModuleException extends RuntimeException {
constructor(metatypeUsedAsAModule: any, scope: any[]);
constructor(metatypeUsedAsAModule: any, scope: any[], classKind: 'provider' | 'controller' | 'filter');
}

@@ -7,6 +7,6 @@ "use strict";

class InvalidClassModuleException extends runtime_exception_1.RuntimeException {
constructor(metatypeUsedAsAModule, scope) {
super((0, messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE)(metatypeUsedAsAModule, scope));
constructor(metatypeUsedAsAModule, scope, classKind) {
super((0, messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE)(metatypeUsedAsAModule, scope, classKind));
}
}
exports.InvalidClassModuleException = InvalidClassModuleException;
import { RuntimeException } from './runtime.exception';
export declare class InvalidModuleException extends RuntimeException {
constructor(parentModule: any, index: number, scope: any[]);
constructor(parentModule: any, index: number, scope: any[], receivedValue: unknown);
}

@@ -7,6 +7,6 @@ "use strict";

class InvalidModuleException extends runtime_exception_1.RuntimeException {
constructor(parentModule, index, scope) {
super((0, messages_1.INVALID_MODULE_MESSAGE)(parentModule, index, scope));
constructor(parentModule, index, scope, receivedValue) {
super((0, messages_1.INVALID_MODULE_MESSAGE)(parentModule, index, scope, receivedValue));
}
}
exports.InvalidModuleException = InvalidModuleException;

@@ -7,4 +7,4 @@ import type { ForwardReference, Type } from '@nestjs/common';

export declare const UNDEFINED_FORWARDREF_MESSAGE: (scope: Type<any>[]) => string;
export declare const INVALID_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
export declare const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE: (metatypeUsedAsAModule: Type | ForwardReference, scope: any[]) => string;
export declare const INVALID_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[], receivedValue: unknown) => string;
export declare const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE: (metatypeUsedAsAModule: Type | ForwardReference, scope: any[], classKind: "provider" | "controller" | "filter") => string;
export declare const UNDEFINED_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;

@@ -11,0 +11,0 @@ export declare const UNKNOWN_EXPORT_MESSAGE: (token: string | symbol | undefined, module: string) => string;

@@ -120,6 +120,21 @@ "use strict";

exports.UNDEFINED_FORWARDREF_MESSAGE = UNDEFINED_FORWARDREF_MESSAGE;
const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
const INVALID_MODULE_MESSAGE = (parentModule, index, scope, receivedValue) => {
const parentModuleName = parentModule?.name || 'module';
let formattedValue;
let receivedType;
if (receivedValue === null) {
formattedValue = 'null';
receivedType = 'null';
}
else if (typeof receivedValue === 'string') {
formattedValue = `"${receivedValue}"`;
receivedType = 'string';
}
else {
formattedValue = String(receivedValue);
receivedType = typeof receivedValue;
}
return `Nest cannot create the ${parentModuleName} instance.
Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
The received value \`${formattedValue}\` is of type "${receivedType}".

@@ -129,6 +144,17 @@ Scope [${stringifyScope(scope)}]`;

exports.INVALID_MODULE_MESSAGE = INVALID_MODULE_MESSAGE;
const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope, classKind) => {
const metatypeNameQuote = `"${getInstanceName(metatypeUsedAsAModule)}"`;
return `Classes annotated with @Injectable(), @Catch(), and @Controller() decorators must not appear in the "imports" array of a module.
Please remove ${metatypeNameQuote} (including forwarded occurrences, if any) from all of the "imports" arrays.
let hint;
switch (classKind) {
case 'controller':
hint = `${metatypeNameQuote} is decorated with @Controller() and cannot appear in the "imports" array of a module. Please move ${metatypeNameQuote} to the "controllers" array of the importing module instead.`;
break;
case 'provider':
hint = `${metatypeNameQuote} is decorated with @Injectable() and cannot appear in the "imports" array of a module. Please move ${metatypeNameQuote} to the "providers" array of the importing module instead.`;
break;
case 'filter':
hint = `${metatypeNameQuote} is decorated with @Catch() and cannot appear in the "imports" array of a module. Please move ${metatypeNameQuote} to the "providers" array (using the APP_FILTER token to apply it globally) or apply it via @UseFilters() instead.`;
break;
}
return `${hint}

@@ -135,0 +161,0 @@ Scope [${stringifyScope(scope)}]

@@ -75,5 +75,5 @@ import { InjectionToken } from '@nestjs/common';

getFactoryProviderDependencies<T>(wrapper: InstanceWrapper<T>): [InjectorDependency[], number[]];
reflectConstructorParams<T>(type: Type<T>): any[];
reflectOptionalParams<T>(type: Type<T>): any[];
reflectSelfParams<T>(type: Type<T>): any[];
reflectConstructorParams(type: Type<unknown> | Function): any[];
reflectOptionalParams(type: Type<unknown> | Function): any[];
reflectSelfParams(type: Type<unknown> | Function): any[];
resolveSingleParam<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol, dependencyContext: InjectorDependencyContext, moduleRef: Module, resolutionContext?: ResolutionContext, keyOrIndex?: symbol | string | number): Promise<InstanceWrapper<any>>;

@@ -110,2 +110,3 @@ resolveParamToken<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol | ForwardReference): any;

private getEffectiveResolutionContext;
private hasDenseCtorMetadata;
private resolveScopedComponentHost;

@@ -112,0 +113,0 @@ private isInquirerRequest;

@@ -123,3 +123,4 @@ "use strict";

const metadata = wrapper.getCtorMetadata();
if (metadata && resolutionContext.contextId !== constants_2.STATIC_CONTEXT) {
if (resolutionContext.contextId !== constants_2.STATIC_CONTEXT &&
this.hasDenseCtorMetadata(wrapper, inject, metadata)) {
const deps = await this.loadCtorMetadata(metadata, resolutionContext.contextId, resolutionContext.inquirer, parentInquirer);

@@ -560,2 +561,24 @@ return callback(deps);

}
hasDenseCtorMetadata(wrapper, inject, metadata) {
if (!metadata) {
return false;
}
// The fast path requires a fully populated metadata array.
// While another request is still registering dependency metadata,
// sparse entries here would feed request-scoped factories `undefined`.
const expectedDepsLength = !(0, shared_utils_1.isNil)(inject)
? inject.length
: wrapper.metatype
? this.reflectConstructorParams(wrapper.metatype).length
: 0;
if (metadata.length !== expectedDepsLength) {
return false;
}
for (let index = 0; index < expectedDepsLength; index++) {
if (metadata[index] === undefined) {
return false;
}
}
return true;
}
resolveScopedComponentHost(item, contextId, inquirer, parentInquirer) {

@@ -562,0 +585,0 @@ return this.isInquirerRequest(item, parentInquirer)

{
"name": "@nestjs/core",
"version": "11.1.21",
"version": "11.1.22",
"description": "Nest - modern, fast, powerful node.js web framework (@core)",

@@ -42,3 +42,3 @@ "author": "Kamil Mysliwiec",

"devDependencies": {
"@nestjs/common": "11.1.21"
"@nestjs/common": "11.1.22"
},

@@ -64,3 +64,3 @@ "peerDependencies": {

},
"gitHead": "983dd52c4927753be3421162fc43e4fde8d3fcde"
"gitHead": "801c46ffa19d2a549adc446d1f91e7484ae61edb"
}

@@ -67,3 +67,3 @@ "use strict";

if (!innerModule) {
throw new invalid_module_exception_1.InvalidModuleException(moduleDefinition, index, scope);
throw new invalid_module_exception_1.InvalidModuleException(moduleDefinition, index, scope, innerModule);
}

@@ -94,7 +94,11 @@ if (ctxRegistry.includes(innerModule)) {

: moduleDefinition;
if (this.isInjectable(moduleToAdd) ||
this.isController(moduleToAdd) ||
this.isExceptionFilter(moduleToAdd)) {
throw new invalid_class_module_exception_1.InvalidClassModuleException(moduleDefinition, scope);
if (this.isInjectable(moduleToAdd)) {
throw new invalid_class_module_exception_1.InvalidClassModuleException(moduleDefinition, scope, 'provider');
}
if (this.isController(moduleToAdd)) {
throw new invalid_class_module_exception_1.InvalidClassModuleException(moduleDefinition, scope, 'controller');
}
if (this.isExceptionFilter(moduleToAdd)) {
throw new invalid_class_module_exception_1.InvalidClassModuleException(moduleDefinition, scope, 'filter');
}
return this.container.addModule(moduleToAdd, scope);

@@ -101,0 +105,0 @@ }