@tsed/schema 6.72.3 → 6.73.3
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/lib/constants/httpMethods.d.ts +12 -0
- package/lib/decorators/index.d.ts +1 -0
- package/lib/decorators/operations/operationPath.d.ts +1 -11
- package/lib/decorators/operations/route.d.ts +185 -0
- package/lib/domain/DecoratorContext.d.ts +7 -2
- package/lib/domain/JsonEntityStore.d.ts +10 -10
- package/lib/index.d.ts +1 -0
- package/lib/index.js +287 -25
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +279 -27
- package/lib/index.modern.js.map +1 -1
- package/lib/utils/mapRouteOptions.d.ts +5 -0
- package/package.json +5 -5
|
@@ -24,6 +24,7 @@ export * from "./operations/summary";
|
|
|
24
24
|
export * from "./operations/partial";
|
|
25
25
|
export * from "./operations/redirect";
|
|
26
26
|
export * from "./operations/location";
|
|
27
|
+
export * from "./operations/route";
|
|
27
28
|
export * from "./common/additionalProperties";
|
|
28
29
|
export * from "./common/allow";
|
|
29
30
|
export * from "./common/any";
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
ALL = "ALL",
|
|
3
|
-
GET = "GET",
|
|
4
|
-
POST = "POST",
|
|
5
|
-
PUT = "PUT",
|
|
6
|
-
PATCH = "PATCH",
|
|
7
|
-
HEAD = "HEAD",
|
|
8
|
-
DELETE = "DELETE",
|
|
9
|
-
OPTIONS = "OPTIONS",
|
|
10
|
-
CUSTOM = "CUSTOM"
|
|
11
|
-
}
|
|
1
|
+
import { OperationMethods } from "../../constants/httpMethods";
|
|
12
2
|
/**
|
|
13
3
|
* Declare new Operation with his path and http method.
|
|
14
4
|
*
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { OperationMethods } from "../../constants/httpMethods";
|
|
2
|
+
export interface RouteChainedDecorators {
|
|
3
|
+
<T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
|
|
4
|
+
/**
|
|
5
|
+
* @param string
|
|
6
|
+
* @constructor
|
|
7
|
+
*/
|
|
8
|
+
Path(string: string): this;
|
|
9
|
+
/**
|
|
10
|
+
* Set the operation method
|
|
11
|
+
* @param method
|
|
12
|
+
*/
|
|
13
|
+
Method(method: OperationMethods | string): this;
|
|
14
|
+
/**
|
|
15
|
+
* Set the operation id
|
|
16
|
+
* @param id
|
|
17
|
+
*/
|
|
18
|
+
Id(id: string): this;
|
|
19
|
+
/**
|
|
20
|
+
* Set the operation id
|
|
21
|
+
* @param name
|
|
22
|
+
*/
|
|
23
|
+
Name(name: string): this;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param description
|
|
27
|
+
*/
|
|
28
|
+
Description(description: string): this;
|
|
29
|
+
/**
|
|
30
|
+
* Summary
|
|
31
|
+
* @constructor
|
|
32
|
+
* @param Summary
|
|
33
|
+
*/
|
|
34
|
+
Summary(Summary: string): this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Describe a new route with a method and path.
|
|
38
|
+
*
|
|
39
|
+
* ```typescript
|
|
40
|
+
* @Controller('/')
|
|
41
|
+
* export class Ctrl {
|
|
42
|
+
*
|
|
43
|
+
* @Route('GET', '/')
|
|
44
|
+
* get() { }
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @returns {Function}
|
|
50
|
+
* @param method
|
|
51
|
+
* @param path
|
|
52
|
+
* @param args
|
|
53
|
+
* @decorator
|
|
54
|
+
* @operation
|
|
55
|
+
*/
|
|
56
|
+
export declare function Route(method: string, path: string, ...args: any[]): RouteChainedDecorators;
|
|
57
|
+
export declare function Route(...args: any[]): RouteChainedDecorators;
|
|
58
|
+
/**
|
|
59
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
60
|
+
*
|
|
61
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
62
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
63
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
64
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
65
|
+
* to continue matching subsequent routes.
|
|
66
|
+
* @param path
|
|
67
|
+
* @param args
|
|
68
|
+
* @returns {Function}
|
|
69
|
+
* @decorator
|
|
70
|
+
* @operation
|
|
71
|
+
* @httpMethod
|
|
72
|
+
*/
|
|
73
|
+
export declare function All(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
74
|
+
/**
|
|
75
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
76
|
+
*
|
|
77
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
78
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
79
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
80
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
81
|
+
* to continue matching subsequent routes.
|
|
82
|
+
* @param path
|
|
83
|
+
* @param args
|
|
84
|
+
* @returns {Function}
|
|
85
|
+
* @decorator
|
|
86
|
+
* @operation
|
|
87
|
+
* @httpMethod
|
|
88
|
+
*/
|
|
89
|
+
export declare function Get(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
90
|
+
/**
|
|
91
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
92
|
+
*
|
|
93
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
94
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
95
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
96
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
97
|
+
* to continue matching subsequent routes.
|
|
98
|
+
* @param path
|
|
99
|
+
* @param args
|
|
100
|
+
* @returns {Function}
|
|
101
|
+
* @decorator
|
|
102
|
+
* @operation
|
|
103
|
+
* @httpMethod
|
|
104
|
+
*/
|
|
105
|
+
export declare function Post(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
106
|
+
/**
|
|
107
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
108
|
+
*
|
|
109
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
110
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
111
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
112
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
113
|
+
* to continue matching subsequent routes.
|
|
114
|
+
* @param path
|
|
115
|
+
* @param args
|
|
116
|
+
* @returns {Function}
|
|
117
|
+
* @decorator
|
|
118
|
+
* @operation
|
|
119
|
+
* @httpMethod
|
|
120
|
+
*/
|
|
121
|
+
export declare function Put(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
122
|
+
/**
|
|
123
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
124
|
+
*
|
|
125
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
126
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
127
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
128
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
129
|
+
* to continue matching subsequent routes.
|
|
130
|
+
* @param path
|
|
131
|
+
* @param args
|
|
132
|
+
* @returns {Function}
|
|
133
|
+
* @decorator
|
|
134
|
+
* @operation
|
|
135
|
+
* @httpMethod
|
|
136
|
+
*/
|
|
137
|
+
export declare function Delete(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
138
|
+
/**
|
|
139
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
140
|
+
*
|
|
141
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
142
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
143
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
144
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
145
|
+
* to continue matching subsequent routes.
|
|
146
|
+
* @param path
|
|
147
|
+
* @param args
|
|
148
|
+
* @returns {Function}
|
|
149
|
+
* @decorator
|
|
150
|
+
* @operation
|
|
151
|
+
* @httpMethod
|
|
152
|
+
*/
|
|
153
|
+
export declare function Head(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
154
|
+
/**
|
|
155
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
156
|
+
*
|
|
157
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
158
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
159
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
160
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
161
|
+
* to continue matching subsequent routes.
|
|
162
|
+
* @param path
|
|
163
|
+
* @param args
|
|
164
|
+
* @returns {Function}
|
|
165
|
+
* @decorator
|
|
166
|
+
* @operation
|
|
167
|
+
* @httpMethod
|
|
168
|
+
*/
|
|
169
|
+
export declare function Patch(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
170
|
+
/**
|
|
171
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
172
|
+
*
|
|
173
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
174
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
175
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
176
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
177
|
+
* to continue matching subsequent routes.
|
|
178
|
+
* @param path
|
|
179
|
+
* @param args
|
|
180
|
+
* @returns {Function}
|
|
181
|
+
* @decorator
|
|
182
|
+
* @operation
|
|
183
|
+
* @httpMethod
|
|
184
|
+
*/
|
|
185
|
+
export declare function Options(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
|
|
@@ -12,12 +12,17 @@ export interface DecoratorActionHandler {
|
|
|
12
12
|
export declare abstract class DecoratorContext<T = any> extends Map<string, any> {
|
|
13
13
|
readonly methods: string[];
|
|
14
14
|
protected decoratorType: DecoratorTypes;
|
|
15
|
-
protected
|
|
15
|
+
protected entity: JsonEntityStore;
|
|
16
16
|
protected actions: DecoratorActionHandler[];
|
|
17
|
+
constructor(opts?: any);
|
|
17
18
|
addAction(cb: DecoratorActionHandler): this;
|
|
18
19
|
build(): T;
|
|
19
20
|
toObject(): any;
|
|
20
21
|
getMergedKey(key: string, defaultValue: any): any;
|
|
21
|
-
protected
|
|
22
|
+
protected bind(args: DecoratorParameters, decorator: any): void;
|
|
23
|
+
protected onInit(args: DecoratorParameters, decorator: any): void;
|
|
24
|
+
protected onMapKey(key: string, value: any): void;
|
|
22
25
|
protected runActions(): this;
|
|
26
|
+
protected beforeInit(): void;
|
|
27
|
+
protected afterInit(): void;
|
|
23
28
|
}
|
|
@@ -16,28 +16,28 @@ export declare class JsonEntityStore extends Entity implements JsonEntityStoreOp
|
|
|
16
16
|
* Path used to generate open spec.
|
|
17
17
|
*/
|
|
18
18
|
path: string;
|
|
19
|
+
constructor(options: JsonEntityStoreOptions);
|
|
19
20
|
/**
|
|
20
21
|
* Ref to JsonSchema
|
|
21
22
|
*/
|
|
22
23
|
protected _schema: JsonSchema;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
protected _operation: JsonOperation;
|
|
27
|
-
/**
|
|
28
|
-
* Ref to JsonParameter when the decorated object is a parameter.
|
|
25
|
+
* Return the JsonSchema
|
|
29
26
|
*/
|
|
30
|
-
|
|
27
|
+
get schema(): JsonSchema;
|
|
31
28
|
[key: string]: any;
|
|
32
|
-
constructor(options: JsonEntityStoreOptions);
|
|
33
29
|
/**
|
|
34
|
-
*
|
|
30
|
+
* Ref to JsonOperation when the decorated object is a method.
|
|
35
31
|
*/
|
|
36
|
-
|
|
32
|
+
protected _operation: JsonOperation;
|
|
37
33
|
/**
|
|
38
34
|
* Return the JsonOperation
|
|
39
35
|
*/
|
|
40
36
|
get operation(): JsonOperation | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Ref to JsonParameter when the decorated object is a parameter.
|
|
39
|
+
*/
|
|
40
|
+
protected _parameter: JsonParameter;
|
|
41
41
|
/**
|
|
42
42
|
* Return the JsonParameter
|
|
43
43
|
*/
|
|
@@ -79,7 +79,7 @@ export declare class JsonEntityStore extends Entity implements JsonEntityStoreOp
|
|
|
79
79
|
*/
|
|
80
80
|
static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): NonNullable<T>;
|
|
81
81
|
static fromMethod(target: any, propertyKey: string | symbol): JsonEntityStore;
|
|
82
|
-
getResponseOptions(contentType?: string): undefined | any;
|
|
82
|
+
getResponseOptions(status: number, contentType?: string): undefined | any;
|
|
83
83
|
/**
|
|
84
84
|
* Check precondition between value, required and allowedRequiredValues to know if the entity is required.
|
|
85
85
|
* @param value
|