@eggjs/controller-decorator 4.0.0-beta.8 → 4.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/ControllerMetaBuilderFactory.d.ts +7 -0
- package/dist/builder/ControllerMetaBuilderFactory.js +41 -0
- package/dist/builder/index.d.ts +1 -0
- package/dist/builder/index.js +2 -0
- package/dist/decorator/Acl.d.ts +1 -0
- package/dist/decorator/Acl.js +22 -0
- package/dist/decorator/Context.d.ts +1 -0
- package/dist/decorator/Context.js +11 -0
- package/dist/decorator/Middleware.d.ts +2 -0
- package/dist/decorator/Middleware.js +69 -0
- package/dist/decorator/http/HTTPController.d.ts +2 -0
- package/dist/decorator/http/HTTPController.js +29 -0
- package/dist/decorator/http/HTTPMethod.d.ts +2 -0
- package/dist/decorator/http/HTTPMethod.js +17 -0
- package/dist/decorator/http/HTTPParam.d.ts +8 -0
- package/dist/decorator/http/HTTPParam.js +75 -0
- package/dist/decorator/http/Host.d.ts +2 -0
- package/dist/decorator/http/Host.js +25 -0
- package/dist/decorator/http/index.d.ts +4 -0
- package/dist/decorator/http/index.js +5 -0
- package/dist/decorator/index.d.ts +4 -0
- package/dist/decorator/index.js +5 -0
- package/dist/impl/http/HTTPControllerMetaBuilder.d.ts +9 -0
- package/dist/impl/http/HTTPControllerMetaBuilder.js +57 -0
- package/dist/impl/http/HTTPControllerMethodMetaBuilder.d.ts +11 -0
- package/dist/impl/http/HTTPControllerMethodMetaBuilder.js +100 -0
- package/dist/impl/http/index.d.ts +2 -0
- package/dist/impl/http/index.js +3 -0
- package/dist/impl/index.d.ts +1 -0
- package/dist/impl/index.js +2 -0
- package/dist/index.d.ts +6 -248
- package/dist/index.js +7 -752
- package/dist/model/HTTPControllerMeta.d.ts +22 -0
- package/dist/model/HTTPControllerMeta.js +60 -0
- package/dist/model/HTTPCookies.d.ts +3 -0
- package/dist/model/HTTPCookies.js +4 -0
- package/dist/model/HTTPMethodMeta.d.ts +56 -0
- package/dist/model/HTTPMethodMeta.js +124 -0
- package/dist/model/HTTPRequest.d.ts +7 -0
- package/dist/model/HTTPRequest.js +3 -0
- package/dist/model/HTTPResponse.d.ts +10 -0
- package/dist/model/HTTPResponse.js +3 -0
- package/dist/model/index.d.ts +5 -0
- package/dist/model/index.js +6 -0
- package/dist/util/ControllerInfoUtil.d.ts +17 -0
- package/dist/util/ControllerInfoUtil.js +46 -0
- package/dist/util/ControllerMetadataUtil.d.ts +5 -0
- package/dist/util/ControllerMetadataUtil.js +20 -0
- package/dist/util/HTTPInfoUtil.d.ts +16 -0
- package/dist/util/HTTPInfoUtil.js +64 -0
- package/dist/util/HTTPPriorityUtil.d.ts +19 -0
- package/dist/util/HTTPPriorityUtil.js +42 -0
- package/dist/util/MethodInfoUtil.d.ts +20 -0
- package/dist/util/MethodInfoUtil.js +72 -0
- package/dist/util/index.d.ts +6 -0
- package/dist/util/index.js +7 -0
- package/dist/util/validator/ControllerValidator.d.ts +4 -0
- package/dist/util/validator/ControllerValidator.js +15 -0
- package/dist/util/validator/MethodValidator.d.ts +4 -0
- package/dist/util/validator/MethodValidator.js +31 -0
- package/dist/util/validator/index.d.ts +2 -0
- package/dist/util/validator/index.js +3 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,248 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
private static builderCreatorMap;
|
|
8
|
-
static registerControllerMetaBuilder(controllerType: ControllerTypeLike, controllerBuilderCreator: ControllerMetaBuilderCreator): void;
|
|
9
|
-
static createControllerMetaBuilder(clazz: EggProtoImplClass, controllerType?: ControllerTypeLike): ControllerMetaBuilder | undefined;
|
|
10
|
-
static build(clazz: EggProtoImplClass, controllerType?: ControllerTypeLike): ControllerMetadata | undefined;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/decorator/http/Host.d.ts
|
|
14
|
-
declare function Host(host: HostType): (target: any, propertyKey?: PropertyKey) => void;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/decorator/http/HTTPController.d.ts
|
|
17
|
-
declare function HTTPController(param?: HTTPControllerParams): (constructor: EggProtoImplClass) => void;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/decorator/http/HTTPMethod.d.ts
|
|
20
|
-
declare function HTTPMethod(param: HTTPMethodParams): (target: any, propertyKey: PropertyKey) => void;
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/decorator/http/HTTPParam.d.ts
|
|
23
|
-
declare function HTTPBody(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
24
|
-
declare function HTTPHeaders(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
25
|
-
declare function HTTPQuery(param?: HTTPQueryParams): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
26
|
-
declare function HTTPQueries(param?: HTTPQueriesParams): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
27
|
-
declare function HTTPParam(param?: HTTPParamParams): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
28
|
-
declare function Request$1(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
29
|
-
declare function Cookies(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/decorator/Acl.d.ts
|
|
32
|
-
declare function Acl(code?: string): (target: any, propertyKey?: PropertyKey) => void;
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/decorator/Context.d.ts
|
|
35
|
-
declare function Context(): (target: any, propertyKey: PropertyKey, parameterIndex: number) => void;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/decorator/Middleware.d.ts
|
|
38
|
-
declare function Middleware(...middlewares: Array<MiddlewareFunc> | Array<EggProtoImplClass<IAdvice>>): (target: any, propertyKey?: PropertyKey) => void;
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/model/HTTPMethodMeta.d.ts
|
|
41
|
-
declare abstract class ParamMeta {
|
|
42
|
-
type: HTTPParamType;
|
|
43
|
-
abstract validate(httpPath: string): void;
|
|
44
|
-
}
|
|
45
|
-
declare class RequestParamMeta extends ParamMeta {
|
|
46
|
-
type: HTTPParamType;
|
|
47
|
-
validate(): void;
|
|
48
|
-
}
|
|
49
|
-
declare class BodyParamMeta extends ParamMeta {
|
|
50
|
-
type: HTTPParamType;
|
|
51
|
-
validate(): void;
|
|
52
|
-
}
|
|
53
|
-
declare class HeadersParamMeta extends ParamMeta {
|
|
54
|
-
type: HTTPParamType;
|
|
55
|
-
validate(): void;
|
|
56
|
-
}
|
|
57
|
-
declare class QueryParamMeta extends ParamMeta {
|
|
58
|
-
type: HTTPParamType;
|
|
59
|
-
name: string;
|
|
60
|
-
constructor(name: string);
|
|
61
|
-
validate(): void;
|
|
62
|
-
}
|
|
63
|
-
declare class QueriesParamMeta extends ParamMeta {
|
|
64
|
-
type: HTTPParamType;
|
|
65
|
-
name: string;
|
|
66
|
-
constructor(name: string);
|
|
67
|
-
validate(): void;
|
|
68
|
-
}
|
|
69
|
-
declare class PathParamMeta extends ParamMeta {
|
|
70
|
-
type: HTTPParamType;
|
|
71
|
-
name: string;
|
|
72
|
-
constructor(name: string);
|
|
73
|
-
validate(httpPath: string): void;
|
|
74
|
-
}
|
|
75
|
-
declare class CookiesParamMeta extends ParamMeta {
|
|
76
|
-
type: HTTPParamType;
|
|
77
|
-
validate(): void;
|
|
78
|
-
}
|
|
79
|
-
declare class HTTPMethodMeta implements MethodMeta {
|
|
80
|
-
readonly name: string;
|
|
81
|
-
readonly path: string;
|
|
82
|
-
readonly method: HTTPMethodEnum;
|
|
83
|
-
readonly middlewares: readonly MiddlewareFunc[];
|
|
84
|
-
readonly contextParamIndex: number | undefined;
|
|
85
|
-
readonly paramMap: Map<number, ParamMeta>;
|
|
86
|
-
readonly priority: number;
|
|
87
|
-
readonly needAcl: boolean;
|
|
88
|
-
readonly aclCode: string | undefined;
|
|
89
|
-
readonly hosts: string[] | undefined;
|
|
90
|
-
constructor(name: string, path: string, method: HTTPMethodEnum, middlewares: MiddlewareFunc[], contextParamIndex: number | undefined, paramTypeMap: Map<number, ParamMeta>, priority: number, needAcl: boolean, aclCode: string | undefined, hosts: string[] | undefined);
|
|
91
|
-
}
|
|
92
|
-
declare class ParamMetaUtil {
|
|
93
|
-
static createParam(type: HTTPParamType, name?: string): RequestParamMeta | BodyParamMeta | HeadersParamMeta | QueryParamMeta | QueriesParamMeta | PathParamMeta | CookiesParamMeta;
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/model/HTTPControllerMeta.d.ts
|
|
97
|
-
declare class HTTPControllerMeta implements ControllerMetadata {
|
|
98
|
-
readonly protoName: EggPrototypeName;
|
|
99
|
-
readonly controllerName: string;
|
|
100
|
-
readonly className: string;
|
|
101
|
-
readonly type = ControllerType.HTTP;
|
|
102
|
-
readonly path?: string;
|
|
103
|
-
readonly middlewares: readonly MiddlewareFunc[];
|
|
104
|
-
readonly methods: readonly HTTPMethodMeta[];
|
|
105
|
-
readonly needAcl: boolean;
|
|
106
|
-
readonly aclCode?: string;
|
|
107
|
-
readonly hosts?: string[];
|
|
108
|
-
constructor(className: string, protoName: EggPrototypeName, controllerName: string, path: string | undefined, middlewares: MiddlewareFunc[], methods: HTTPMethodMeta[], needAcl: boolean, aclCode: string | undefined, hosts: string[] | undefined);
|
|
109
|
-
getMethodRealPath(method: HTTPMethodMeta): string;
|
|
110
|
-
getMethodHosts(method: HTTPMethodMeta): string[] | undefined;
|
|
111
|
-
getMethodName(method: HTTPMethodMeta): string;
|
|
112
|
-
getMethodMiddlewares(method: HTTPMethodMeta): MiddlewareFunc[];
|
|
113
|
-
hasMethodAcl(method: HTTPMethodMeta): boolean;
|
|
114
|
-
getMethodAcl(method: HTTPMethodMeta): string | undefined;
|
|
115
|
-
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/model/HTTPCookies.d.ts
|
|
118
|
-
declare class HTTPCookies extends Cookies$1 {}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/model/HTTPRequest.d.ts
|
|
121
|
-
declare const HTTPRequest_base: ObjectConstructor | {
|
|
122
|
-
new (input: RequestInfo | URL, init?: RequestInit): Request;
|
|
123
|
-
prototype: Request;
|
|
124
|
-
};
|
|
125
|
-
declare class HTTPRequest extends HTTPRequest_base {}
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/model/HTTPResponse.d.ts
|
|
128
|
-
declare const HTTPResponse_base: {
|
|
129
|
-
new (body?: BodyInit | null, init?: ResponseInit): Response;
|
|
130
|
-
prototype: Response;
|
|
131
|
-
error(): Response;
|
|
132
|
-
json(data: any, init?: ResponseInit): Response;
|
|
133
|
-
redirect(url: string | URL, status?: number): Response;
|
|
134
|
-
} | ObjectConstructor;
|
|
135
|
-
declare class HTTPResponse extends HTTPResponse_base {}
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region src/impl/http/HTTPControllerMetaBuilder.d.ts
|
|
138
|
-
declare class HTTPControllerMetaBuilder {
|
|
139
|
-
private readonly clazz;
|
|
140
|
-
constructor(clazz: EggProtoImplClass);
|
|
141
|
-
private buildMethod;
|
|
142
|
-
build(): HTTPControllerMeta;
|
|
143
|
-
static create(clazz: EggProtoImplClass): HTTPControllerMetaBuilder;
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/impl/http/HTTPControllerMethodMetaBuilder.d.ts
|
|
147
|
-
declare class HTTPControllerMethodMetaBuilder {
|
|
148
|
-
private readonly clazz;
|
|
149
|
-
private readonly methodName;
|
|
150
|
-
constructor(clazz: EggProtoImplClass, methodName: string);
|
|
151
|
-
private checkParamDecorators;
|
|
152
|
-
private buildParamType;
|
|
153
|
-
getPriority(): number;
|
|
154
|
-
build(): HTTPMethodMeta | undefined;
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/util/validator/ControllerValidator.d.ts
|
|
158
|
-
declare class ControllerValidator {
|
|
159
|
-
static validate(clazz: EggProtoImplClass): void;
|
|
160
|
-
}
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/util/validator/MethodValidator.d.ts
|
|
163
|
-
declare class MethodValidator {
|
|
164
|
-
static validate(clazz: EggProtoImplClass, methodName: string): void;
|
|
165
|
-
}
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region src/util/ControllerInfoUtil.d.ts
|
|
168
|
-
declare class ControllerInfoUtil {
|
|
169
|
-
static addControllerMiddleware(middleware: MiddlewareFunc, clazz: EggProtoImplClass): void;
|
|
170
|
-
static addControllerAopMiddleware(middleware: EggProtoImplClass<IAdvice>, clazz: EggProtoImplClass): void;
|
|
171
|
-
static getControllerMiddlewares(clazz: EggProtoImplClass): MiddlewareFunc[];
|
|
172
|
-
static getControllerAopMiddlewares(clazz: EggProtoImplClass): EggProtoImplClass<IAdvice>[];
|
|
173
|
-
static setControllerType(clazz: EggProtoImplClass, controllerType: ControllerTypeLike): void;
|
|
174
|
-
static setControllerName(clazz: EggProtoImplClass, controllerName: string): void;
|
|
175
|
-
static getControllerName(clazz: EggProtoImplClass): string | undefined;
|
|
176
|
-
static getControllerType(clazz: EggProtoImplClass): ControllerTypeLike | undefined;
|
|
177
|
-
static setControllerAcl(code: string | undefined, clazz: EggProtoImplClass): void;
|
|
178
|
-
static hasControllerAcl(clazz: EggProtoImplClass): boolean;
|
|
179
|
-
static getControllerAcl(clazz: EggProtoImplClass): string | undefined;
|
|
180
|
-
static addControllerHosts(hosts: string[], clazz: EggProtoImplClass): void;
|
|
181
|
-
static getControllerHosts(clazz: EggProtoImplClass): string[] | undefined;
|
|
182
|
-
}
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/util/ControllerMetadataUtil.d.ts
|
|
185
|
-
declare class ControllerMetadataUtil {
|
|
186
|
-
static setControllerMetadata(clazz: EggProtoImplClass, metaData: ControllerMetadata): void;
|
|
187
|
-
static getControllerMetadata(clazz: EggProtoImplClass): ControllerMetadata | undefined;
|
|
188
|
-
}
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region src/util/HTTPInfoUtil.d.ts
|
|
191
|
-
declare class HTTPInfoUtil {
|
|
192
|
-
static setHTTPPath(path: string, clazz: EggProtoImplClass): void;
|
|
193
|
-
static getHTTPPath(clazz: EggProtoImplClass): string | undefined;
|
|
194
|
-
static setHTTPMethodPath(path: string, clazz: EggProtoImplClass, methodName: string): void;
|
|
195
|
-
static getHTTPMethodPath(clazz: EggProtoImplClass, methodName: string): string | undefined;
|
|
196
|
-
static setHTTPMethodMethod(method: HTTPMethodEnum, clazz: EggProtoImplClass, methodName: string): void;
|
|
197
|
-
static getHTTPMethodMethod(clazz: EggProtoImplClass, methodName: string): HTTPMethodEnum | undefined;
|
|
198
|
-
static setHTTPMethodParamType(paramType: HTTPParamType, parameterIndex: number, clazz: EggProtoImplClass, methodName: string): void;
|
|
199
|
-
static getParamIndexList(clazz: EggProtoImplClass, methodName: string): number[];
|
|
200
|
-
static getHTTPMethodParamType(parameterIndex: number, clazz: EggProtoImplClass, methodName: string): HTTPParamType | undefined;
|
|
201
|
-
static setHTTPMethodParamName(paramName: string, parameterIndex: number, clazz: EggProtoImplClass, methodName: string): void;
|
|
202
|
-
static getHTTPMethodParamName(parameterIndex: number, clazz: EggProtoImplClass, methodName: string): string | undefined;
|
|
203
|
-
static getHTTPMethodPriority(clazz: EggProtoImplClass, methodName: string): number | undefined;
|
|
204
|
-
static setHTTPMethodPriority(priority: number, clazz: EggProtoImplClass, methodName: string): void;
|
|
205
|
-
}
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/util/HTTPPriorityUtil.d.ts
|
|
208
|
-
declare class HTTPPriorityUtil {
|
|
209
|
-
static readonly DEFAULT_PRIORITY = 100000;
|
|
210
|
-
private static readonly TOKEN_PRIORITY;
|
|
211
|
-
/**
|
|
212
|
-
* | Path | RegExp index | priority |
|
|
213
|
-
* | --- | --- | --- |
|
|
214
|
-
* | /* | [0] | 0 |
|
|
215
|
-
* | /hello/:name | [1] | 1000 |
|
|
216
|
-
* | /hello/world/message/:message | [3] | 3000 |
|
|
217
|
-
* | /hello/:name/message/:message | [1, 3] | 4000 |
|
|
218
|
-
* | /hello/world | [] | 100000/Infinity? |
|
|
219
|
-
*
|
|
220
|
-
* priority = hasRegExp
|
|
221
|
-
* : regexpIndex.reduce((p,c) => p + c * 1000, 0)
|
|
222
|
-
* : 100000;
|
|
223
|
-
* @param {string} path -
|
|
224
|
-
*/
|
|
225
|
-
static calcPathPriority(path: string): number;
|
|
226
|
-
}
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/util/MethodInfoUtil.d.ts
|
|
229
|
-
declare class MethodInfoUtil {
|
|
230
|
-
static setMethodControllerType(clazz: EggProtoImplClass, methodName: string, controllerType: ControllerTypeLike): void;
|
|
231
|
-
static getMethodControllerType(clazz: EggProtoImplClass, methodName: string): ControllerTypeLike | undefined;
|
|
232
|
-
static setMethodContextIndexInArgs(index: number, clazz: EggProtoImplClass, methodName: string): void;
|
|
233
|
-
static getMethodContextIndex(clazz: EggProtoImplClass, methodName: string): number | undefined;
|
|
234
|
-
static addMethodMiddleware(middleware: MiddlewareFunc, clazz: EggProtoImplClass, methodName: string): void;
|
|
235
|
-
static getMethodMiddlewares(clazz: EggProtoImplClass, methodName: string): MiddlewareFunc[];
|
|
236
|
-
static addMethodAopMiddleware(middleware: EggProtoImplClass<IAdvice>, clazz: EggProtoImplClass, methodName: string): void;
|
|
237
|
-
static getMethodAopMiddlewares(clazz: EggProtoImplClass, methodName: string): EggProtoImplClass<IAdvice>[];
|
|
238
|
-
static setMethodAcl(code: string | undefined, clazz: EggProtoImplClass, methodName: string): void;
|
|
239
|
-
static hasMethodAcl(clazz: EggProtoImplClass, methodName: string): boolean;
|
|
240
|
-
static getMethodAcl(clazz: EggProtoImplClass, methodName: string): string | undefined;
|
|
241
|
-
static setMethodHosts(hosts: string[], clazz: EggProtoImplClass, methodName: string): void;
|
|
242
|
-
static getMethodHosts(clazz: EggProtoImplClass, methodName: string): string[] | undefined;
|
|
243
|
-
static getMethods(clazz: EggProtoImplClass): string[];
|
|
244
|
-
static shouldRegisterAopMiddlewarePointCut(clazz: EggProtoImplClass, methodName: string): boolean;
|
|
245
|
-
static registerAopMiddlewarePointcut(clazz: EggProtoImplClass, methodName: string): void;
|
|
246
|
-
}
|
|
247
|
-
//#endregion
|
|
248
|
-
export { Acl, BodyParamMeta, Context, ControllerInfoUtil, ControllerMetaBuilderFactory, ControllerMetadataUtil, ControllerValidator, Cookies, CookiesParamMeta, HTTPBody, HTTPController, HTTPControllerMeta, HTTPControllerMetaBuilder, HTTPControllerMethodMetaBuilder, HTTPCookies, HTTPHeaders, HTTPInfoUtil, HTTPMethod, HTTPMethodMeta, HTTPParam, HTTPPriorityUtil, HTTPQueries, HTTPQuery, HTTPRequest, HTTPResponse, HeadersParamMeta, Host, MethodInfoUtil, MethodValidator, Middleware, ParamMeta, ParamMetaUtil, PathParamMeta, QueriesParamMeta, QueryParamMeta, Request$1 as Request, RequestParamMeta };
|
|
1
|
+
export * from '@eggjs/tegg-types/controller-decorator';
|
|
2
|
+
export * from './builder/index.ts';
|
|
3
|
+
export * from './decorator/index.ts';
|
|
4
|
+
export * from './impl/index.ts';
|
|
5
|
+
export * from './model/index.ts';
|
|
6
|
+
export * from './util/index.ts';
|