@tsed/schema 6.80.0 → 6.83.0

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,17 @@
1
+ function printMemory(event) {
2
+ const used = process.memoryUsage();
3
+ const obj = {event};
4
+
5
+ for (let key in used) {
6
+ // console.log(`${key} ${} MB`);
7
+ obj[key] = Math.round((used[key] / 1024 / 1024) * 100) / 100;
8
+ }
9
+
10
+ obj.timestamp = Date.now();
11
+
12
+ console.log(JSON.stringify(obj));
13
+ }
14
+ console.time("benchmark");
15
+ require("@tsed/schema");
16
+ console.timeEnd("benchmark");
17
+ printMemory();
@@ -1,5 +1,272 @@
1
1
  export declare const HTTP_STATUS_MESSAGES: {
2
- [key: string]: string;
2
+ "100": {
3
+ label: string;
4
+ code: string;
5
+ };
6
+ "101": {
7
+ label: string;
8
+ code: string;
9
+ };
10
+ "102": {
11
+ label: string;
12
+ code: string;
13
+ };
14
+ "103": {
15
+ label: string;
16
+ code: string;
17
+ };
18
+ "200": {
19
+ label: string;
20
+ code: string;
21
+ };
22
+ "201": {
23
+ label: string;
24
+ code: string;
25
+ };
26
+ "202": {
27
+ label: string;
28
+ code: string;
29
+ };
30
+ "203": {
31
+ label: string;
32
+ code: string;
33
+ };
34
+ "204": {
35
+ label: string;
36
+ code: string;
37
+ };
38
+ "205": {
39
+ label: string;
40
+ code: string;
41
+ };
42
+ "206": {
43
+ label: string;
44
+ code: string;
45
+ };
46
+ "207": {
47
+ label: string;
48
+ code: string;
49
+ };
50
+ "208": {
51
+ label: string;
52
+ code: string;
53
+ };
54
+ "226": {
55
+ label: string;
56
+ code: string;
57
+ };
58
+ "300": {
59
+ label: string;
60
+ code: string;
61
+ };
62
+ "301": {
63
+ label: string;
64
+ code: string;
65
+ };
66
+ "302": {
67
+ label: string;
68
+ code: string;
69
+ };
70
+ "303": {
71
+ label: string;
72
+ code: string;
73
+ };
74
+ "304": {
75
+ label: string;
76
+ code: string;
77
+ };
78
+ "305": {
79
+ label: string;
80
+ code: string;
81
+ };
82
+ "306": {
83
+ label: string;
84
+ code: string;
85
+ };
86
+ "307": {
87
+ label: string;
88
+ code: string;
89
+ };
90
+ "308": {
91
+ label: string;
92
+ code: string;
93
+ };
94
+ "310": {
95
+ label: string;
96
+ code: string;
97
+ };
98
+ "400": {
99
+ label: string;
100
+ code: string;
101
+ };
102
+ "401": {
103
+ label: string;
104
+ code: string;
105
+ };
106
+ "402": {
107
+ label: string;
108
+ code: string;
109
+ };
110
+ "403": {
111
+ label: string;
112
+ code: string;
113
+ };
114
+ "404": {
115
+ label: string;
116
+ code: string;
117
+ };
118
+ "405": {
119
+ label: string;
120
+ code: string;
121
+ };
122
+ "406": {
123
+ label: string;
124
+ code: string;
125
+ };
126
+ "407": {
127
+ label: string;
128
+ code: string;
129
+ };
130
+ "408": {
131
+ label: string;
132
+ code: string;
133
+ };
134
+ "409": {
135
+ label: string;
136
+ code: string;
137
+ };
138
+ "410": {
139
+ label: string;
140
+ code: string;
141
+ };
142
+ "411": {
143
+ label: string;
144
+ code: string;
145
+ };
146
+ "412": {
147
+ label: string;
148
+ code: string;
149
+ };
150
+ "413": {
151
+ label: string;
152
+ code: string;
153
+ };
154
+ "414": {
155
+ label: string;
156
+ code: string;
157
+ };
158
+ "415": {
159
+ label: string;
160
+ code: string;
161
+ };
162
+ "416": {
163
+ label: string;
164
+ code: string;
165
+ };
166
+ "417": {
167
+ label: string;
168
+ code: string;
169
+ };
170
+ "418": {
171
+ label: string;
172
+ code: string;
173
+ };
174
+ "421": {
175
+ label: string;
176
+ code: string;
177
+ };
178
+ "422": {
179
+ label: string;
180
+ code: string;
181
+ };
182
+ "423": {
183
+ label: string;
184
+ code: string;
185
+ };
186
+ "424": {
187
+ label: string;
188
+ code: string;
189
+ };
190
+ "425": {
191
+ label: string;
192
+ code: string;
193
+ };
194
+ "426": {
195
+ label: string;
196
+ code: string;
197
+ };
198
+ "427": {
199
+ label: string;
200
+ code: string;
201
+ };
202
+ "428": {
203
+ label: string;
204
+ code: string;
205
+ };
206
+ "429": {
207
+ label: string;
208
+ code: string;
209
+ };
210
+ "430": {
211
+ label: string;
212
+ code: string;
213
+ };
214
+ "431": {
215
+ label: string;
216
+ code: string;
217
+ };
218
+ "451": {
219
+ label: string;
220
+ code: string;
221
+ };
222
+ "500": {
223
+ label: string;
224
+ code: string;
225
+ };
226
+ "501": {
227
+ label: string;
228
+ code: string;
229
+ };
230
+ "502": {
231
+ label: string;
232
+ code: string;
233
+ };
234
+ "503": {
235
+ label: string;
236
+ code: string;
237
+ };
238
+ "504": {
239
+ label: string;
240
+ code: string;
241
+ };
242
+ "505": {
243
+ label: string;
244
+ code: string;
245
+ };
246
+ "506": {
247
+ label: string;
248
+ code: string;
249
+ };
250
+ "507": {
251
+ label: string;
252
+ code: string;
253
+ };
254
+ "508": {
255
+ label: string;
256
+ code: string;
257
+ };
258
+ "509": {
259
+ label: string;
260
+ code: string;
261
+ };
262
+ "510": {
263
+ label: string;
264
+ code: string;
265
+ };
266
+ "511": {
267
+ label: string;
268
+ code: string;
269
+ };
3
270
  };
4
- export declare function getStatusConstant(status: number): string;
5
- export declare function getStatusMessage(status: number): string;
271
+ export declare function getStatusConstant(status: number | string): any;
272
+ export declare function getStatusMessage(status: number | string): any;
@@ -31,7 +31,7 @@ export interface ArrayOfChainedDecorators {
31
31
  /**
32
32
  * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.
33
33
  */
34
- UniqueItems(uniqueItems: boolean): this;
34
+ UniqueItems(uniqueItems?: boolean): this;
35
35
  }
36
36
  export interface MapOfChainedDecorators {
37
37
  (...args: any): any;
@@ -1,5 +1,5 @@
1
1
  import { DecoratorParameters } from "@tsed/core";
2
- import { JsonEntityStore } from "../../domain";
2
+ import type { JsonEntityStore } from "../../domain";
3
3
  /**
4
4
  * Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.
5
5
  *
@@ -18,4 +18,4 @@ import { JsonEntityStore } from "../../domain";
18
18
  * @utils
19
19
  * @model
20
20
  */
21
- export declare function JsonEntityFn<T extends JsonEntityStore>(fn: (entity: T, parameters: DecoratorParameters) => any): (...args: any[]) => any;
21
+ export declare function JsonEntityFn<T extends JsonEntityStore = JsonEntityStore>(fn: (entity: T, parameters: DecoratorParameters) => any): (...args: any[]) => any;
@@ -0,0 +1,12 @@
1
+ import type { JsonMethodStore } from "./JsonMethodStore";
2
+ import type { JsonPropertyStore } from "./JsonPropertyStore";
3
+ import { JsonEntityStore } from "./JsonEntityStore";
4
+ export declare class JsonClassStore extends JsonEntityStore {
5
+ /**
6
+ * List of children JsonEntityStore (properties or methods or params)
7
+ */
8
+ readonly children: Map<string | number, JsonMethodStore | JsonPropertyStore>;
9
+ get path(): string;
10
+ set path(path: string);
11
+ protected build(): void;
12
+ }
@@ -1,45 +1,101 @@
1
- import { Entity, EntityOptions, Store, Type } from "@tsed/core";
2
- import { JsonOperation } from "./JsonOperation";
3
- import { JsonParameter } from "./JsonParameter";
4
- import { JsonSchema } from "./JsonSchema";
5
- export interface JsonEntityStoreOptions extends EntityOptions {
1
+ import { DecoratorTypes, Store, Type } from "@tsed/core";
2
+ import type { JsonSchema } from "./JsonSchema";
3
+ import type { JsonMethodStore } from "./JsonMethodStore";
4
+ import type { JsonClassStore } from "./JsonClassStore";
5
+ import type { JsonPropertyStore } from "./JsonPropertyStore";
6
+ import type { JsonParameterStore } from "./JsonParameterStore";
7
+ /**
8
+ * @ignore
9
+ */
10
+ export declare const JsonEntitiesContainer: Map<DecoratorTypes, Type<JsonEntityStore>>;
11
+ export interface JsonEntityStoreOptions {
12
+ decoratorType: DecoratorTypes;
13
+ target: Type<any>;
14
+ propertyKey?: string | symbol;
15
+ index?: number;
16
+ descriptor?: any;
17
+ type?: Type<any>;
18
+ collectionType?: Type<any>;
6
19
  [key: string]: any;
7
20
  }
8
- export declare class JsonEntityStore extends Entity implements JsonEntityStoreOptions {
21
+ export declare abstract class JsonEntityStore implements JsonEntityStoreOptions {
22
+ /**
23
+ * Original property key decorated by the decorator
24
+ */
25
+ readonly propertyKey: string | symbol;
26
+ /**
27
+ * Alias of the property
28
+ */
29
+ readonly propertyName: string;
30
+ /**
31
+ * Parameter index
32
+ */
33
+ readonly index: number;
34
+ /**
35
+ * Method's descriptor
36
+ */
37
+ readonly descriptor: number;
38
+ /**
39
+ * Decorator type used to declare the JsonSchemaStore.
40
+ */
41
+ readonly decoratorType: DecoratorTypes;
42
+ /**
43
+ * Type of the collection (Array, Map, Set, etc...)
44
+ */
45
+ collectionType: Type<any>;
46
+ token: Type<any>;
9
47
  readonly store: Store;
10
48
  readonly isStore = true;
49
+ readonly parent: JsonEntityStore;
50
+ readonly target: Type<any>;
11
51
  /**
12
- * List of children JsonEntityStore (properties or methods or params)
52
+ *
13
53
  */
14
- readonly children: Map<string | number, JsonEntityStore>;
54
+ protected _type: Type<any>;
15
55
  /**
16
56
  * Ref to JsonSchema
17
57
  */
18
58
  protected _schema: JsonSchema;
59
+ [key: string]: any;
60
+ constructor(options: JsonEntityStoreOptions);
19
61
  /**
20
- * Ref to JsonOperation when the decorated object is a method.
62
+ * Return the class name of the entity.
63
+ * @returns {string}
21
64
  */
22
- protected _operation: JsonOperation;
65
+ get targetName(): string;
23
66
  /**
24
- * Ref to JsonParameter when the decorated object is a parameter.
67
+ *
68
+ * @returns {boolean}
25
69
  */
26
- protected _parameter: JsonParameter;
27
- [key: string]: any;
28
- constructor(options: JsonEntityStoreOptions);
29
- get path(): string;
30
- set path(path: string);
70
+ get isCollection(): boolean;
31
71
  /**
32
- * Return the JsonSchema
72
+ *
73
+ * @returns {boolean}
33
74
  */
34
- get schema(): JsonSchema;
75
+ get isArray(): boolean;
76
+ /**
77
+ *
78
+ * @returns {boolean}
79
+ */
80
+ get isPrimitive(): boolean;
81
+ /**
82
+ *
83
+ * @returns {boolean}
84
+ */
85
+ get isDate(): boolean;
86
+ /**
87
+ *
88
+ * @returns {boolean}
89
+ */
90
+ get isObject(): boolean;
35
91
  /**
36
- * Return the JsonOperation
92
+ *
37
93
  */
38
- get operation(): JsonOperation | undefined;
94
+ get isClass(): boolean;
39
95
  /**
40
- * Return the JsonParameter
96
+ * Return the JsonSchema
41
97
  */
42
- get parameter(): JsonParameter | undefined;
98
+ get schema(): JsonSchema;
43
99
  get nestedGenerics(): Type<any>[][];
44
100
  set nestedGenerics(nestedGenerics: Type<any>[][]);
45
101
  /**
@@ -59,34 +115,18 @@ export declare class JsonEntityStore extends Entity implements JsonEntityStoreOp
59
115
  get computedType(): any;
60
116
  get itemSchema(): JsonSchema;
61
117
  get parentSchema(): JsonSchema;
62
- get parent(): JsonEntityStore;
63
- /**
64
- * Return the required state.
65
- * @returns {boolean}
66
- */
67
- get required(): boolean;
68
- /**
69
- * Change the state of the required data.
70
- * @param value
71
- */
72
- set required(value: boolean);
73
- get allowedRequiredValues(): any[];
74
118
  /**
75
119
  *
76
- * @param args
120
+ * @param target
77
121
  */
122
+ static from<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;
123
+ static from<T extends JsonPropertyStore = JsonPropertyStore>(target: Type<any> | any, propertyKey: string | symbol): T;
124
+ static from<T extends JsonParameterStore = JsonParameterStore>(target: Type<any> | any, propertyKey: string | symbol, index: number): T;
125
+ static from<T extends JsonMethodStore = JsonMethodStore>(target: Type<any> | any, propertyKey: string | symbol, descriptor: PropertyDescriptor): T;
78
126
  static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T;
79
- static fromMethod(target: any, propertyKey: string | symbol): JsonEntityStore;
127
+ static fromMethod<T extends JsonMethodStore = JsonMethodStore>(target: any, propertyKey: string | symbol): T;
80
128
  get<T = any>(key: string, defaultValue?: any): T;
81
- getResponseOptions(status: number, contentType?: string): undefined | any;
82
- /**
83
- * Check precondition between value, required and allowedRequiredValues to know if the entity is required.
84
- * @param value
85
- * @returns {boolean}
86
- */
87
- isRequired(value: any): boolean;
88
- protected build(): void;
89
- protected createProperty(): any;
90
- protected createOperation(): JsonOperation;
91
- protected createParameter(): JsonParameter;
129
+ set(key: string, value?: any): Store;
130
+ protected abstract build(): void;
131
+ protected buildType(type: any): void;
92
132
  }
@@ -0,0 +1,19 @@
1
+ import { JsonEntityStore } from "./JsonEntityStore";
2
+ import { JsonOperation } from "./JsonOperation";
3
+ import type { JsonParameterStore } from "./JsonParameterStore";
4
+ import type { JsonClassStore } from "./JsonClassStore";
5
+ export declare class JsonMethodStore extends JsonEntityStore {
6
+ readonly parent: JsonClassStore;
7
+ /**
8
+ * Ref to JsonOperation when the decorated object is a method.
9
+ */
10
+ readonly operation: JsonOperation;
11
+ /**
12
+ * List of children JsonEntityStore (properties or methods or params)
13
+ */
14
+ readonly children: Map<string | number, JsonParameterStore>;
15
+ get parameters(): JsonParameterStore[];
16
+ get operationPaths(): Map<string, import("./JsonOperation").JsonMethodPath>;
17
+ getResponseOptions(status: number, contentType?: string): undefined | any;
18
+ protected build(): void;
19
+ }
@@ -1,5 +1,5 @@
1
1
  import { Type } from "@tsed/core";
2
- import { JsonMethodPath } from "./JsonOperation";
2
+ import { JsonMethodPath, JsonOperation } from "./JsonOperation";
3
3
  import { JsonEntityStore } from "./JsonEntityStore";
4
4
  export declare class JsonOperationRoute<Entity extends JsonEntityStore = JsonEntityStore> {
5
5
  readonly token: Type<any>;
@@ -7,10 +7,18 @@ export declare class JsonOperationRoute<Entity extends JsonEntityStore = JsonEnt
7
7
  readonly operationPath?: JsonMethodPath;
8
8
  readonly basePath?: string;
9
9
  constructor(options: Partial<JsonOperationRoute>);
10
+ get url(): string;
10
11
  get path(): string | RegExp | undefined;
11
12
  get fullPath(): string;
12
13
  get method(): string;
13
14
  get isFinal(): boolean;
14
- get propertyKey(): string | symbol;
15
+ get name(): string;
16
+ get className(): string;
17
+ get methodClassName(): string;
18
+ get parameters(): any;
19
+ get propertyKey(): string;
20
+ get propertyName(): string;
15
21
  get store(): import("@tsed/core").Store;
22
+ get operation(): JsonOperation;
23
+ get operationId(): any;
16
24
  }
@@ -8,6 +8,7 @@ export declare class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> imp
8
8
  nestedGenerics: Type<any>[][];
9
9
  groups: string[];
10
10
  $schema: JsonSchema;
11
+ expression: string;
11
12
  getName(): any;
12
13
  name(name: string): this;
13
14
  examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>): this;
@@ -0,0 +1,30 @@
1
+ import { Type } from "@tsed/core";
2
+ import { JsonEntityStore } from "./JsonEntityStore";
3
+ import type { JsonMethodStore } from "./JsonMethodStore";
4
+ import { JsonParameter } from "./JsonParameter";
5
+ import { JsonSchema } from "./JsonSchema";
6
+ export declare class JsonParameterStore extends JsonEntityStore {
7
+ /**
8
+ * Ref to JsonParameter when the decorated object is a parameter.
9
+ */
10
+ readonly parameter: JsonParameter;
11
+ readonly parent: JsonMethodStore;
12
+ get nestedGenerics(): Type<any>[][];
13
+ set nestedGenerics(nestedGenerics: Type<any>[][]);
14
+ /**
15
+ * Return the required state.
16
+ * @returns {boolean}
17
+ */
18
+ get required(): boolean;
19
+ set required(value: boolean);
20
+ get allowedRequiredValues(): any[];
21
+ static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[];
22
+ /**
23
+ * Check precondition between value, required and allowedRequiredValues to know if the entity is required.
24
+ * @param value
25
+ * @returns {boolean}
26
+ */
27
+ isRequired(value: any): boolean;
28
+ protected getSchema(type: any): JsonSchema;
29
+ protected build(): void;
30
+ }
@@ -0,0 +1,23 @@
1
+ import { JsonEntityStore } from "./JsonEntityStore";
2
+ import type { JsonClassStore } from "./JsonClassStore";
3
+ export declare class JsonPropertyStore extends JsonEntityStore {
4
+ readonly parent: JsonClassStore;
5
+ /**
6
+ * Return the required state.
7
+ * @returns {boolean}
8
+ */
9
+ get required(): boolean;
10
+ /**
11
+ * Change the state of the required data.
12
+ * @param value
13
+ */
14
+ set required(value: boolean);
15
+ get allowedRequiredValues(): any[];
16
+ /**
17
+ * Check precondition between value, required and allowedRequiredValues to know if the entity is required.
18
+ * @param value
19
+ * @returns {boolean}
20
+ */
21
+ isRequired(value: any): boolean;
22
+ protected build(): void;
23
+ }
@@ -7,6 +7,10 @@ export * from "./JsonSchema";
7
7
  export * from "./JsonFormatTypes";
8
8
  export * from "./SpecTypes";
9
9
  export * from "./JsonEntityStore";
10
+ export * from "./JsonClassStore";
11
+ export * from "./JsonMethodStore";
12
+ export * from "./JsonParameterStore";
13
+ export * from "./JsonPropertyStore";
10
14
  export * from "./JsonOperationRoute";
11
15
  export * from "./JsonParameterTypes";
12
16
  export * from "./JsonLazyRef";