@nestjs/core
Version:
The core of NestJS, a TypeScript framework for Node.js backends: modules, dependency injection and the request pipeline, on Express, Fastify or node:http.
46 lines (45 loc) • 2.54 kB
TypeScript
import type { ParamData } from '@nestjs/common';
import { ExecutionContextHost } from './execution-context-host.js';
import { type Controller } from '@nestjs/common/internal';
import type { ContextType, PipeTransform } from '@nestjs/common';
import type { StandardSchemaV1 } from '@standard-schema/spec';
export interface ParamProperties<T = any, IExtractor extends Function = any> {
index: number;
type: T | string;
data: ParamData;
pipes: PipeTransform[];
extractValue: IExtractor;
schema?: StandardSchemaV1;
}
export declare class ContextUtils {
mapParamType(key: string): string;
reflectCallbackParamtypes(instance: Controller, methodName: string): any[];
reflectCallbackMetadata<T = any>(instance: Controller, methodName: string, metadataKey: string): T;
reflectPassthrough(instance: Controller, methodName: string): boolean;
/**
* Returns the class that the parameter decorators of the given handler
* stored their metadata on (see `getParamsHost`).
*/
private getParamsHost;
getArgumentsLength<T>(keys: string[], metadata: T): number;
createNullArray(length: number): any[];
mergeParamsMetatypes(paramsProperties: ParamProperties[], paramtypes: any[]): (ParamProperties & {
metatype?: any;
})[];
/**
* A handler has parameter types only if its compiler emits decorator
* metadata, and tsx and esbuild don't. Without them a `ValidationPipe` has
* nothing to validate a parameter against and passes it on as it came, so
* this says so once per handler, when the handler is set up. It doesn't
* throw, as the handler may not rely on the pipe. A parameter whose
* `ValidationPipe` was given an `expectedType` needs no metadata, so it isn't
* reported, and neither is a custom decorator's, which `ValidationPipe`
* skips by default.
*
* @param pipes pipes bound to the handler (global, class and method ones)
* @param paramsProperties parameters the pipes are applied to
*/
warnOnMissingParamtypes(instance: Controller, methodName: string, paramtypes: unknown[] | undefined, pipes: PipeTransform[], paramsProperties: ParamProperties[]): void;
getCustomFactory(factory: (...args: unknown[]) => void, data: unknown, contextFactory: (args: unknown[]) => ExecutionContextHost): (...args: unknown[]) => unknown;
getContextFactory<TContext extends string = ContextType>(contextType: TContext, instance?: object, callback?: Function): (args: unknown[]) => ExecutionContextHost;
}