@tsed/schema 6.72.2 → 6.73.2

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.
@@ -0,0 +1,12 @@
1
+ export declare const HTTP_METHODS: string[];
2
+ export declare enum OperationMethods {
3
+ ALL = "ALL",
4
+ GET = "GET",
5
+ POST = "POST",
6
+ PUT = "PUT",
7
+ PATCH = "PATCH",
8
+ HEAD = "HEAD",
9
+ DELETE = "DELETE",
10
+ OPTIONS = "OPTIONS",
11
+ CUSTOM = "CUSTOM"
12
+ }
@@ -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
- export declare enum OperationMethods {
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 store: JsonEntityStore;
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 abstract onInit(args: DecoratorParameters, decorator: any): void;
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
- * Ref to JsonOperation when the decorated object is a method.
25
- */
26
- protected _operation: JsonOperation;
27
- /**
28
- * Ref to JsonParameter when the decorated object is a parameter.
25
+ * Return the JsonSchema
29
26
  */
30
- protected _parameter: JsonParameter;
27
+ get schema(): JsonSchema;
31
28
  [key: string]: any;
32
- constructor(options: JsonEntityStoreOptions);
33
29
  /**
34
- * Return the JsonSchema
30
+ * Ref to JsonOperation when the decorated object is a method.
35
31
  */
36
- get schema(): JsonSchema;
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
  */
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./constants/httpStatusMessages";
2
+ export * from "./constants/httpMethods";
2
3
  export * from "./utils/getJsonSchema";
3
4
  export * from "./utils/getJsonType";
4
5
  export * from "./utils/getPropertiesStores";