@tsed/schema 6.97.2 → 6.98.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/cjs/decorators/common/enum.js +1 -20
- package/lib/cjs/decorators/common/enum.js.map +1 -1
- package/lib/cjs/decorators/index.js +2 -0
- package/lib/cjs/decorators/index.js.map +1 -1
- package/lib/cjs/decorators/operations/acceptMime.js +28 -0
- package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
- package/lib/cjs/decorators/operations/view.js +31 -0
- package/lib/cjs/decorators/operations/view.js.map +1 -0
- package/lib/cjs/domain/JsonMethodStore.js +37 -1
- package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
- package/lib/cjs/domain/JsonOperationRoute.js +7 -0
- package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
- package/lib/cjs/domain/JsonParameter.js +4 -2
- package/lib/cjs/domain/JsonParameter.js.map +1 -1
- package/lib/cjs/domain/JsonParameterStore.js +13 -4
- package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
- package/lib/cjs/domain/JsonPropertyStore.js +5 -1
- package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
- package/lib/cjs/domain/JsonSchema.js +4 -11
- package/lib/cjs/domain/JsonSchema.js.map +1 -1
- package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
- package/lib/cjs/utils/mapNullableType.js +1 -1
- package/lib/cjs/utils/mapNullableType.js.map +1 -1
- package/lib/cjs/utils/serializeEnumValues.js +35 -0
- package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
- package/lib/esm/decorators/common/enum.js +1 -20
- package/lib/esm/decorators/common/enum.js.map +1 -1
- package/lib/esm/decorators/index.js +2 -0
- package/lib/esm/decorators/index.js.map +1 -1
- package/lib/esm/decorators/operations/acceptMime.js +24 -0
- package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
- package/lib/esm/decorators/operations/view.js +27 -0
- package/lib/esm/decorators/operations/view.js.map +1 -0
- package/lib/esm/domain/JsonMethodStore.js +37 -1
- package/lib/esm/domain/JsonMethodStore.js.map +1 -1
- package/lib/esm/domain/JsonOperationRoute.js +7 -0
- package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
- package/lib/esm/domain/JsonParameter.js +4 -2
- package/lib/esm/domain/JsonParameter.js.map +1 -1
- package/lib/esm/domain/JsonParameterStore.js +13 -4
- package/lib/esm/domain/JsonParameterStore.js.map +1 -1
- package/lib/esm/domain/JsonPropertyStore.js +4 -0
- package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
- package/lib/esm/domain/JsonSchema.js +4 -11
- package/lib/esm/domain/JsonSchema.js.map +1 -1
- package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
- package/lib/esm/utils/mapNullableType.js +1 -1
- package/lib/esm/utils/mapNullableType.js.map +1 -1
- package/lib/esm/utils/serializeEnumValues.js +30 -0
- package/lib/esm/utils/serializeEnumValues.js.map +1 -0
- package/lib/types/decorators/index.d.ts +2 -0
- package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
- package/lib/types/decorators/operations/view.d.ts +23 -0
- package/lib/types/domain/JsonMethodStore.d.ts +48 -0
- package/lib/types/domain/JsonOperationRoute.d.ts +5 -3
- package/lib/types/domain/JsonParameterStore.d.ts +23 -1
- package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
- package/lib/types/domain/JsonSchema.d.ts +1 -1
- package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
- package/lib/types/utils/mapNullableType.d.ts +1 -1
- package/lib/types/utils/serializeEnumValues.d.ts +5 -0
- package/package.json +7 -7
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use a view and sends the rendered HTML string to the client. Optional parameter:
|
|
3
|
+
*
|
|
4
|
+
* * viewOptions, an object whose properties define local variables for the view.
|
|
5
|
+
*
|
|
6
|
+
* The view argument is a string that is the file path of the view file to render.
|
|
7
|
+
* This can be an absolute path, or a path relative to the views setting.
|
|
8
|
+
* If the path does not contain a file extension, then the view engine setting determines the file extension.
|
|
9
|
+
* If the path does contain a file extension, then Express will load the module for the specified template engine (via require())
|
|
10
|
+
* and render it using the loaded module’s __express function.
|
|
11
|
+
*
|
|
12
|
+
* For more information, see [Using template engines with Express](http://expressjs.com/guide/using-template-engines.html).
|
|
13
|
+
*
|
|
14
|
+
* > NOTE: The view argument performs file system operations like reading a file from disk and evaluating Node.js modules,
|
|
15
|
+
* and as so for security reasons should not contain input from the end-user.
|
|
16
|
+
*
|
|
17
|
+
* @param path Relative path to the view file.
|
|
18
|
+
* @param options Additional options
|
|
19
|
+
* @decorator
|
|
20
|
+
* @operation
|
|
21
|
+
* @response
|
|
22
|
+
*/
|
|
23
|
+
export declare function View(path: string, options?: Object): MethodDecorator;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
1
2
|
import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore";
|
|
2
3
|
import { JsonOperation } from "./JsonOperation";
|
|
3
4
|
import type { JsonParameterStore } from "./JsonParameterStore";
|
|
4
5
|
import type { JsonClassStore } from "./JsonClassStore";
|
|
6
|
+
export interface JsonViewOptions {
|
|
7
|
+
path: string;
|
|
8
|
+
options: any;
|
|
9
|
+
}
|
|
10
|
+
export interface JsonRedirectOptions {
|
|
11
|
+
status: number | undefined;
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
5
14
|
export declare class JsonMethodStore extends JsonEntityStore {
|
|
6
15
|
readonly parent: JsonClassStore;
|
|
7
16
|
middlewares: any[];
|
|
@@ -16,6 +25,11 @@ export declare class JsonMethodStore extends JsonEntityStore {
|
|
|
16
25
|
* List of children JsonEntityStore (properties or methods or params)
|
|
17
26
|
*/
|
|
18
27
|
readonly children: Map<string | number, JsonParameterStore>;
|
|
28
|
+
get params(): JsonParameterStore[];
|
|
29
|
+
get view(): JsonViewOptions;
|
|
30
|
+
set view(view: JsonViewOptions);
|
|
31
|
+
get acceptMimes(): string[];
|
|
32
|
+
set acceptMimes(mimes: string[]);
|
|
19
33
|
get parameters(): JsonParameterStore[];
|
|
20
34
|
get operationPaths(): Map<string, import("./JsonOperation").JsonMethodPath>;
|
|
21
35
|
getResponseOptions(status: number, contentType?: string): undefined | any;
|
|
@@ -37,4 +51,38 @@ export declare class JsonMethodStore extends JsonEntityStore {
|
|
|
37
51
|
* @param args
|
|
38
52
|
*/
|
|
39
53
|
use(args: Function[]): this;
|
|
54
|
+
/**
|
|
55
|
+
* Find the value at the controller level. Let this value be extended or overridden by the endpoint itself.
|
|
56
|
+
*
|
|
57
|
+
* @param key
|
|
58
|
+
* @returns {any}
|
|
59
|
+
*/
|
|
60
|
+
get<T = any>(key: any): T;
|
|
61
|
+
/**
|
|
62
|
+
* Get an endpoint.
|
|
63
|
+
* @param target
|
|
64
|
+
* @param propertyKey
|
|
65
|
+
* @param descriptor
|
|
66
|
+
*/
|
|
67
|
+
static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): JsonMethodStore;
|
|
40
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* EndpointMetadata contains metadata about a controller and his method.
|
|
71
|
+
* Each annotation (@Get, @Body...) attached to a method are stored into endpoint.
|
|
72
|
+
* EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.
|
|
73
|
+
*
|
|
74
|
+
* Example :
|
|
75
|
+
*```typescript
|
|
76
|
+
* @Controller("/my-path")
|
|
77
|
+
* provide MyClass {
|
|
78
|
+
*
|
|
79
|
+
* @Get("/")
|
|
80
|
+
* @Authenticated()
|
|
81
|
+
* public myMethod(){}
|
|
82
|
+
* }
|
|
83
|
+
*```
|
|
84
|
+
*
|
|
85
|
+
* @alias JsonMethodStore
|
|
86
|
+
*/
|
|
87
|
+
export declare type EndpointMetadata = JsonMethodStore;
|
|
88
|
+
export declare const EndpointMetadata: typeof JsonMethodStore;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
+
import { JsonMethodStore } from "./JsonMethodStore";
|
|
2
3
|
import { JsonMethodPath, JsonOperation } from "./JsonOperation";
|
|
3
|
-
|
|
4
|
-
export declare class JsonOperationRoute<Entity extends JsonEntityStore = JsonEntityStore> {
|
|
4
|
+
export declare class JsonOperationRoute<Entity extends JsonMethodStore = JsonMethodStore> {
|
|
5
5
|
readonly token: Type<any>;
|
|
6
6
|
readonly endpoint: Entity;
|
|
7
7
|
readonly operationPath?: JsonMethodPath;
|
|
8
8
|
readonly basePath?: string;
|
|
9
|
+
readonly paramsTypes: Record<string, boolean>;
|
|
9
10
|
constructor(options: Partial<JsonOperationRoute>);
|
|
10
11
|
get url(): string;
|
|
11
12
|
get path(): string | RegExp | undefined;
|
|
@@ -15,10 +16,11 @@ export declare class JsonOperationRoute<Entity extends JsonEntityStore = JsonEnt
|
|
|
15
16
|
get name(): string;
|
|
16
17
|
get className(): string;
|
|
17
18
|
get methodClassName(): string;
|
|
18
|
-
get parameters():
|
|
19
|
+
get parameters(): import("./JsonParameterStore").JsonParameterStore[];
|
|
19
20
|
get propertyKey(): string;
|
|
20
21
|
get propertyName(): string;
|
|
21
22
|
get store(): import("@tsed/core").Store;
|
|
22
23
|
get operation(): JsonOperation;
|
|
23
24
|
get operationId(): any;
|
|
25
|
+
has(key: string): boolean;
|
|
24
26
|
}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import { JsonEntityStore } from "./JsonEntityStore";
|
|
2
|
+
import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore";
|
|
3
3
|
import type { JsonMethodStore } from "./JsonMethodStore";
|
|
4
4
|
import { JsonParameter } from "./JsonParameter";
|
|
5
5
|
import { JsonSchema } from "./JsonSchema";
|
|
6
|
+
export interface JsonParameterStoreOptions extends JsonEntityStoreOptions {
|
|
7
|
+
dataPath?: string;
|
|
8
|
+
paramType?: string;
|
|
9
|
+
expression?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PipeMethods<T = any, R = any> {
|
|
12
|
+
transform(value: T, metadata: JsonParameterStore): R;
|
|
13
|
+
}
|
|
6
14
|
export declare class JsonParameterStore extends JsonEntityStore {
|
|
15
|
+
paramType: string;
|
|
16
|
+
expression: string;
|
|
17
|
+
dataPath: string;
|
|
18
|
+
/**
|
|
19
|
+
* Define pipes can be called by the framework to transform input parameter
|
|
20
|
+
*/
|
|
21
|
+
pipes: Type<PipeMethods>[];
|
|
7
22
|
/**
|
|
8
23
|
* Ref to JsonParameter when the decorated object is a parameter.
|
|
9
24
|
*/
|
|
10
25
|
readonly parameter: JsonParameter;
|
|
11
26
|
readonly parent: JsonMethodStore;
|
|
27
|
+
constructor(options: JsonParameterStoreOptions);
|
|
12
28
|
get nestedGenerics(): Type<any>[][];
|
|
13
29
|
set nestedGenerics(nestedGenerics: Type<any>[][]);
|
|
14
30
|
/**
|
|
@@ -19,6 +35,7 @@ export declare class JsonParameterStore extends JsonEntityStore {
|
|
|
19
35
|
set required(value: boolean);
|
|
20
36
|
get allowedRequiredValues(): any[];
|
|
21
37
|
static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[];
|
|
38
|
+
static get(target: Type<any>, propertyKey: string | symbol, index: number): JsonParameterStore;
|
|
22
39
|
/**
|
|
23
40
|
* Check precondition between value, required and allowedRequiredValues to know if the entity is required.
|
|
24
41
|
* @param value
|
|
@@ -28,3 +45,8 @@ export declare class JsonParameterStore extends JsonEntityStore {
|
|
|
28
45
|
protected getSchema(type: any): JsonSchema;
|
|
29
46
|
protected build(): void;
|
|
30
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* @alias JsonParameterStore
|
|
50
|
+
*/
|
|
51
|
+
export declare type ParamMetadata = JsonParameterStore;
|
|
52
|
+
export declare const ParamMetadata: typeof JsonParameterStore;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
1
2
|
import { JsonEntityStore } from "./JsonEntityStore";
|
|
2
3
|
import type { JsonClassStore } from "./JsonClassStore";
|
|
3
4
|
export declare class JsonPropertyStore extends JsonEntityStore {
|
|
@@ -20,4 +21,10 @@ export declare class JsonPropertyStore extends JsonEntityStore {
|
|
|
20
21
|
*/
|
|
21
22
|
isRequired(value: any): boolean;
|
|
22
23
|
protected build(): void;
|
|
24
|
+
static get(target: Type<any>, propertyKey: string | symbol): JsonPropertyStore;
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* @alias JsonPropertyStore
|
|
28
|
+
*/
|
|
29
|
+
export declare type PropertyMetadata = JsonPropertyStore;
|
|
30
|
+
export declare const PropertyMetadata: typeof JsonPropertyStore;
|
|
@@ -218,7 +218,7 @@ export declare class JsonSchema extends Map<string, any> implements NestedGeneri
|
|
|
218
218
|
*
|
|
219
219
|
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23
|
|
220
220
|
*/
|
|
221
|
-
enum(enumValues:
|
|
221
|
+
enum(...enumValues: any[]): this;
|
|
222
222
|
/**
|
|
223
223
|
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1
|
|
224
224
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
+
import { JsonMethodStore } from "../domain/JsonMethodStore";
|
|
2
3
|
import { JsonOperationRoute } from "../domain/JsonOperationRoute";
|
|
3
|
-
import { JsonEntityStore } from "../domain/JsonEntityStore";
|
|
4
4
|
export interface GetOperationsRoutesOptions {
|
|
5
5
|
withChildren?: boolean;
|
|
6
6
|
basePath?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function getOperationsRoutes<Entity extends
|
|
8
|
+
export declare function getOperationsRoutes<Entity extends JsonMethodStore = JsonMethodStore>(token: Type<any> | any, options?: GetOperationsRoutesOptions): JsonOperationRoute<Entity>[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { JsonSchema } from "../domain/JsonSchema";
|
|
2
2
|
import type { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
3
|
-
export declare function mapNullableType(obj: any, schema: JsonSchema, options: JsonSchemaOptions): any;
|
|
3
|
+
export declare function mapNullableType(obj: any, schema: JsonSchema | null, options: JsonSchemaOptions): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/schema",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.98.3",
|
|
4
4
|
"description": "JsonSchema module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
17
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
18
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
19
|
-
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2
|
|
19
|
+
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"TypeScript",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"tsed"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tsed/core": "6.
|
|
33
|
-
"@tsed/openspec": "6.
|
|
32
|
+
"@tsed/core": "6.98.3",
|
|
33
|
+
"@tsed/openspec": "6.98.3",
|
|
34
34
|
"camel-case": "4.1.2",
|
|
35
35
|
"json-schema": "0.4.0",
|
|
36
|
-
"micromatch": "4.0.
|
|
36
|
+
"micromatch": "4.0.4",
|
|
37
37
|
"pascal-case": "3.1.2",
|
|
38
38
|
"tslib": "2.2.0"
|
|
39
39
|
},
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"fs-extra": "9.0.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@tsed/core": "^6.
|
|
49
|
-
"@tsed/openspec": "^6.
|
|
48
|
+
"@tsed/core": "^6.98.3",
|
|
49
|
+
"@tsed/openspec": "^6.98.3"
|
|
50
50
|
},
|
|
51
51
|
"repository": "https://github.com/tsedio/tsed",
|
|
52
52
|
"bugs": {
|