UNPKG

4.23 kBTypeScriptView Raw
1import { Action } from '../Action';
2import { ActionMetadataArgs } from './args/ActionMetadataArgs';
3import { ActionType } from './types/ActionType';
4import { ClassTransformOptions } from 'class-transformer';
5import { ControllerMetadata } from './ControllerMetadata';
6import { InterceptorMetadata } from './InterceptorMetadata';
7import { ParamMetadata } from './ParamMetadata';
8import { ResponseHandlerMetadata } from './ResponseHandleMetadata';
9import { HandlerOptions } from '../decorator-options/HandlerOptions';
10import { RoutingControllersOptions } from '../RoutingControllersOptions';
11import { UseMetadata } from './UseMetadata';
12/**
13 * Action metadata.
14 */
15export declare class ActionMetadata {
16 private globalOptions;
17 /**
18 * Action's controller.
19 */
20 controllerMetadata: ControllerMetadata;
21 /**
22 * Action's parameters.
23 */
24 params: ParamMetadata[];
25 /**
26 * Action's use metadatas.
27 */
28 uses: UseMetadata[];
29 /**
30 * Action's use interceptors.
31 */
32 interceptors: InterceptorMetadata[];
33 /**
34 * Class on which's method this action is attached.
35 */
36 target: Function;
37 /**
38 * Object's method that will be executed on this action.
39 */
40 method: string;
41 /**
42 * Action-specific options.
43 */
44 options: HandlerOptions;
45 /**
46 * Action type represents http method used for the registered route. Can be one of the value defined in ActionTypes
47 * class.
48 */
49 type: ActionType;
50 /**
51 * Route to be registered for the action.
52 */
53 route: string | RegExp;
54 /**
55 * Full route to this action (includes controller base route).
56 */
57 fullRoute: string | RegExp;
58 /**
59 * Indicates if this action uses Body.
60 */
61 isBodyUsed: boolean;
62 /**
63 * Indicates if this action uses Uploaded File.
64 */
65 isFileUsed: boolean;
66 /**
67 * Indicates if this action uses Uploaded Files.
68 */
69 isFilesUsed: boolean;
70 /**
71 * Indicates if controller of this action is json-typed.
72 */
73 isJsonTyped: boolean;
74 /**
75 * Indicates if this action uses Authorized decorator.
76 */
77 isAuthorizedUsed: boolean;
78 /**
79 * Class-transformer options for the action response content.
80 */
81 responseClassTransformOptions: ClassTransformOptions;
82 /**
83 * Http code to be used on undefined action returned content.
84 */
85 undefinedResultCode: number | Function;
86 /**
87 * Http code to be used on null action returned content.
88 */
89 nullResultCode: number | Function;
90 /**
91 * Http code to be set on successful response.
92 */
93 successHttpCode: number;
94 /**
95 * Specifies redirection url for this action.
96 */
97 redirect: string;
98 /**
99 * Rendered template to be used for this controller action.
100 */
101 renderedTemplate: string;
102 /**
103 * Response headers to be set.
104 */
105 headers: {
106 [name: string]: any;
107 };
108 /**
109 * Extra options used by @Body decorator.
110 */
111 bodyExtraOptions: any;
112 /**
113 * Roles set by @Authorized decorator.
114 */
115 authorizedRoles: any[];
116 /**
117 * Params to be appended to the method call.
118 */
119 appendParams?: (action: Action) => any[];
120 /**
121 * Special function that will be called instead of orignal method of the target.
122 */
123 methodOverride?: (actionMetadata: ActionMetadata, action: Action, params: any[]) => Promise<any> | any;
124 constructor(controllerMetadata: ControllerMetadata, args: ActionMetadataArgs, globalOptions: RoutingControllersOptions);
125 /**
126 * Appends base route to a given regexp route.
127 */
128 static appendBaseRoute(baseRoute: string, route: RegExp | string): string | RegExp;
129 /**
130 * Builds everything action metadata needs.
131 * Action metadata can be used only after its build.
132 */
133 build(responseHandlers: ResponseHandlerMetadata[]): void;
134 /**
135 * Calls action method.
136 * Action method is an action defined in a user controller.
137 */
138 callMethod(params: any[], action: Action): any;
139 /**
140 * Builds full action route.
141 */
142 private buildFullRoute;
143 /**
144 * Builds action response headers.
145 */
146 private buildHeaders;
147}