UNPKG

3.62 kBTypeScriptView Raw
1import { ParamData } from '@nestjs/common';
2import { ContextType, Controller, PipeTransform } from '@nestjs/common/interfaces';
3import { ExternalExceptionFilterContext } from '../exceptions/external-exception-filter-context';
4import { GuardsConsumer, GuardsContextCreator } from '../guards';
5import { NestContainer } from '../injector/container';
6import { ContextId } from '../injector/instance-wrapper';
7import { ModulesContainer } from '../injector/modules-container';
8import { InterceptorsConsumer, InterceptorsContextCreator } from '../interceptors';
9import { PipesConsumer, PipesContextCreator } from '../pipes';
10import { ParamProperties } from './context-utils';
11import { ExternalHandlerMetadata } from './interfaces/external-handler-metadata.interface';
12import { ParamsMetadata } from './interfaces/params-metadata.interface';
13export interface ParamsFactory {
14 exchangeKeyForValue(type: number, data: ParamData, args: any): any;
15}
16export interface ExternalContextOptions {
17 guards?: boolean;
18 interceptors?: boolean;
19 filters?: boolean;
20}
21export declare class ExternalContextCreator {
22 private readonly guardsContextCreator;
23 private readonly guardsConsumer;
24 private readonly interceptorsContextCreator;
25 private readonly interceptorsConsumer;
26 private readonly modulesContainer;
27 private readonly pipesContextCreator;
28 private readonly pipesConsumer;
29 private readonly filtersContextCreator;
30 private readonly contextUtils;
31 private readonly externalErrorProxy;
32 private readonly handlerMetadataStorage;
33 private container;
34 constructor(guardsContextCreator: GuardsContextCreator, guardsConsumer: GuardsConsumer, interceptorsContextCreator: InterceptorsContextCreator, interceptorsConsumer: InterceptorsConsumer, modulesContainer: ModulesContainer, pipesContextCreator: PipesContextCreator, pipesConsumer: PipesConsumer, filtersContextCreator: ExternalExceptionFilterContext);
35 static fromContainer(container: NestContainer): ExternalContextCreator;
36 create<TParamsMetadata extends ParamsMetadata = ParamsMetadata, TContext extends string = ContextType>(instance: Controller, callback: (...args: unknown[]) => unknown, methodName: string, metadataKey?: string, paramsFactory?: ParamsFactory, contextId?: ContextId, inquirerId?: string, options?: ExternalContextOptions, contextType?: TContext): (...args: any[]) => Promise<any>;
37 getMetadata<TMetadata, TContext extends string = ContextType>(instance: Controller, methodName: string, metadataKey?: string, paramsFactory?: ParamsFactory, contextType?: TContext): ExternalHandlerMetadata;
38 getContextModuleKey(moduleCtor: Function | undefined): string;
39 exchangeKeysForValues<TMetadata = any>(keys: string[], metadata: TMetadata, moduleContext: string, paramsFactory: ParamsFactory, contextId?: ContextId, inquirerId?: string, contextFactory?: (args: unknown[]) => import("./execution-context-host").ExecutionContextHost): ParamProperties[];
40 createPipesFn(pipes: PipeTransform[], paramsOptions: (ParamProperties & {
41 metatype?: unknown;
42 })[]): (args: unknown[], ...params: unknown[]) => Promise<void>;
43 getParamValue<T>(value: T, { metatype, type, data }: {
44 metatype: any;
45 type: any;
46 data: any;
47 }, pipes: PipeTransform[]): Promise<any>;
48 transformToResult(resultOrDeferred: any): Promise<any>;
49 createGuardsFn<TContext extends string = ContextType>(guards: any[], instance: Controller, callback: (...args: any[]) => any, contextType?: TContext): Function | null;
50 registerRequestProvider<T = any>(request: T, contextId: ContextId): void;
51}