UNPKG

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