@tsed/platform-params 6.88.1 → 6.89.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.
- package/lib/{builder → cjs/builder}/PlatformParams.d.ts +0 -0
- package/lib/cjs/builder/PlatformParams.js +79 -0
- package/lib/cjs/builder/PlatformParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/bodyParams.d.ts +0 -0
- package/lib/cjs/decorators/bodyParams.js +53 -0
- package/lib/cjs/decorators/bodyParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/context.d.ts +0 -0
- package/lib/cjs/decorators/context.js +19 -0
- package/lib/cjs/decorators/context.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/cookies.d.ts +0 -0
- package/lib/cjs/decorators/cookies.js +24 -0
- package/lib/cjs/decorators/cookies.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/headerParams.d.ts +0 -0
- package/lib/cjs/decorators/headerParams.js +19 -0
- package/lib/cjs/decorators/headerParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/locals.d.ts +0 -0
- package/lib/cjs/decorators/locals.js +19 -0
- package/lib/cjs/decorators/locals.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/paramFn.d.ts +0 -0
- package/lib/cjs/decorators/paramFn.js +22 -0
- package/lib/cjs/decorators/paramFn.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/pathParams.d.ts +0 -0
- package/lib/cjs/decorators/pathParams.js +55 -0
- package/lib/cjs/decorators/pathParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/queryParams.d.ts +0 -0
- package/lib/cjs/decorators/queryParams.js +55 -0
- package/lib/cjs/decorators/queryParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/session.d.ts +0 -0
- package/lib/cjs/decorators/session.js +19 -0
- package/lib/cjs/decorators/session.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useDeserialization.d.ts +0 -0
- package/lib/cjs/decorators/useDeserialization.js +18 -0
- package/lib/cjs/decorators/useDeserialization.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useParam.d.ts +0 -0
- package/lib/cjs/decorators/useParam.js +38 -0
- package/lib/cjs/decorators/useParam.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useParamExpression.d.ts +0 -0
- package/lib/cjs/decorators/useParamExpression.js +20 -0
- package/lib/cjs/decorators/useParamExpression.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useParamType.d.ts +0 -0
- package/lib/cjs/decorators/useParamType.js +26 -0
- package/lib/cjs/decorators/useParamType.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/usePipe.d.ts +0 -0
- package/lib/cjs/decorators/usePipe.js +22 -0
- package/lib/cjs/decorators/usePipe.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useType.d.ts +0 -0
- package/lib/cjs/decorators/useType.js +20 -0
- package/lib/cjs/decorators/useType.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useValidation.d.ts +0 -0
- package/lib/cjs/decorators/useValidation.js +22 -0
- package/lib/cjs/decorators/useValidation.js.map +1 -0
- package/lib/{domain → cjs/domain}/ParamMetadata.d.ts +0 -0
- package/lib/cjs/domain/ParamMetadata.js +34 -0
- package/lib/cjs/domain/ParamMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/ParamOptions.d.ts +0 -0
- package/lib/cjs/domain/ParamOptions.js +3 -0
- package/lib/cjs/domain/ParamOptions.js.map +1 -0
- package/lib/{domain → cjs/domain}/ParamTypes.d.ts +0 -0
- package/lib/cjs/domain/ParamTypes.js +30 -0
- package/lib/cjs/domain/ParamTypes.js.map +1 -0
- package/lib/{errors → cjs/errors}/ParamValidationError.d.ts +0 -0
- package/lib/cjs/errors/ParamValidationError.js +29 -0
- package/lib/cjs/errors/ParamValidationError.js.map +1 -0
- package/lib/{errors → cjs/errors}/RequiredValidationError.d.ts +0 -1
- package/lib/cjs/errors/RequiredValidationError.js +32 -0
- package/lib/cjs/errors/RequiredValidationError.js.map +1 -0
- package/lib/{errors → cjs/errors}/ValidationError.d.ts +0 -0
- package/lib/cjs/errors/ValidationError.js +13 -0
- package/lib/cjs/errors/ValidationError.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +37 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{pipes → cjs/pipes}/DeserializerPipe.d.ts +0 -0
- package/lib/cjs/pipes/DeserializerPipe.js +30 -0
- package/lib/cjs/pipes/DeserializerPipe.js.map +1 -0
- package/lib/{pipes → cjs/pipes}/ParseExpressionPipe.d.ts +0 -0
- package/lib/cjs/pipes/ParseExpressionPipe.js +24 -0
- package/lib/cjs/pipes/ParseExpressionPipe.js.map +1 -0
- package/lib/{pipes → cjs/pipes}/ValidationPipe.d.ts +0 -0
- package/lib/cjs/pipes/ValidationPipe.js +80 -0
- package/lib/cjs/pipes/ValidationPipe.js.map +1 -0
- package/lib/{utils → cjs/utils}/mapParamsOptions.d.ts +0 -0
- package/lib/cjs/utils/mapParamsOptions.js +30 -0
- package/lib/cjs/utils/mapParamsOptions.js.map +1 -0
- package/lib/esm/builder/PlatformParams.js +76 -0
- package/lib/esm/builder/PlatformParams.js.map +1 -0
- package/lib/esm/decorators/bodyParams.js +48 -0
- package/lib/esm/decorators/bodyParams.js.map +1 -0
- package/lib/esm/decorators/context.js +15 -0
- package/lib/esm/decorators/context.js.map +1 -0
- package/lib/esm/decorators/cookies.js +19 -0
- package/lib/esm/decorators/cookies.js.map +1 -0
- package/lib/esm/decorators/headerParams.js +15 -0
- package/lib/esm/decorators/headerParams.js.map +1 -0
- package/lib/esm/decorators/locals.js +15 -0
- package/lib/esm/decorators/locals.js.map +1 -0
- package/lib/esm/decorators/paramFn.js +18 -0
- package/lib/esm/decorators/paramFn.js.map +1 -0
- package/lib/esm/decorators/pathParams.js +50 -0
- package/lib/esm/decorators/pathParams.js.map +1 -0
- package/lib/esm/decorators/queryParams.js +50 -0
- package/lib/esm/decorators/queryParams.js.map +1 -0
- package/lib/esm/decorators/session.js +15 -0
- package/lib/esm/decorators/session.js.map +1 -0
- package/lib/esm/decorators/useDeserialization.js +14 -0
- package/lib/esm/decorators/useDeserialization.js.map +1 -0
- package/lib/esm/decorators/useParam.js +34 -0
- package/lib/esm/decorators/useParam.js.map +1 -0
- package/lib/esm/decorators/useParamExpression.js +16 -0
- package/lib/esm/decorators/useParamExpression.js.map +1 -0
- package/lib/esm/decorators/useParamType.js +22 -0
- package/lib/esm/decorators/useParamType.js.map +1 -0
- package/lib/esm/decorators/usePipe.js +18 -0
- package/lib/esm/decorators/usePipe.js.map +1 -0
- package/lib/esm/decorators/useType.js +16 -0
- package/lib/esm/decorators/useType.js.map +1 -0
- package/lib/esm/decorators/useValidation.js +18 -0
- package/lib/esm/decorators/useValidation.js.map +1 -0
- package/lib/esm/domain/ParamMetadata.js +31 -0
- package/lib/esm/domain/ParamMetadata.js.map +1 -0
- package/lib/esm/domain/ParamOptions.js +2 -0
- package/lib/esm/domain/ParamOptions.js.map +1 -0
- package/lib/esm/domain/ParamTypes.js +27 -0
- package/lib/esm/domain/ParamTypes.js.map +1 -0
- package/lib/esm/errors/ParamValidationError.js +25 -0
- package/lib/esm/errors/ParamValidationError.js.map +1 -0
- package/lib/esm/errors/RequiredValidationError.js +28 -0
- package/lib/esm/errors/RequiredValidationError.js.map +1 -0
- package/lib/esm/errors/ValidationError.js +9 -0
- package/lib/esm/errors/ValidationError.js.map +1 -0
- package/lib/esm/index.js +34 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/pipes/DeserializerPipe.js +27 -0
- package/lib/esm/pipes/DeserializerPipe.js.map +1 -0
- package/lib/esm/pipes/ParseExpressionPipe.js +21 -0
- package/lib/esm/pipes/ParseExpressionPipe.js.map +1 -0
- package/lib/esm/pipes/ValidationPipe.js +77 -0
- package/lib/esm/pipes/ValidationPipe.js.map +1 -0
- package/lib/esm/utils/mapParamsOptions.js +26 -0
- package/lib/esm/utils/mapParamsOptions.js.map +1 -0
- package/lib/types/builder/PlatformParams.d.ts +23 -0
- package/lib/types/decorators/bodyParams.d.ts +64 -0
- package/lib/types/decorators/context.d.ts +59 -0
- package/lib/types/decorators/cookies.d.ts +81 -0
- package/lib/types/decorators/headerParams.d.ts +33 -0
- package/lib/types/decorators/locals.d.ts +42 -0
- package/lib/types/decorators/paramFn.d.ts +11 -0
- package/lib/types/decorators/pathParams.d.ts +68 -0
- package/lib/types/decorators/queryParams.d.ts +73 -0
- package/lib/types/decorators/session.d.ts +36 -0
- package/lib/types/decorators/useDeserialization.d.ts +9 -0
- package/lib/types/decorators/useParam.d.ts +22 -0
- package/lib/types/decorators/useParamExpression.d.ts +10 -0
- package/lib/types/decorators/useParamType.d.ts +10 -0
- package/lib/types/decorators/usePipe.d.ts +13 -0
- package/lib/types/decorators/useType.d.ts +13 -0
- package/lib/types/decorators/useValidation.d.ts +9 -0
- package/lib/types/domain/ParamMetadata.d.ts +16 -0
- package/lib/types/domain/ParamOptions.d.ts +10 -0
- package/lib/types/domain/ParamTypes.d.ts +24 -0
- package/lib/types/errors/ParamValidationError.d.ts +8 -0
- package/lib/types/errors/RequiredValidationError.d.ts +6 -0
- package/lib/types/errors/ValidationError.d.ts +6 -0
- package/lib/types/index.d.ts +28 -0
- package/lib/types/pipes/DeserializerPipe.d.ts +5 -0
- package/lib/types/pipes/ParseExpressionPipe.d.ts +5 -0
- package/lib/types/pipes/ValidationPipe.d.ts +10 -0
- package/lib/types/utils/mapParamsOptions.d.ts +5 -0
- package/package.json +20 -16
- package/tsconfig.compile.esm.json +23 -0
- package/lib/index.js +0 -807
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -788
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ParamOptions } from "../domain/ParamOptions";
|
|
3
|
+
/**
|
|
4
|
+
* HeaderParams return the value from [`request.get()`](http://expressjs.com/en/4x/api.html#req.get) method.
|
|
5
|
+
*
|
|
6
|
+
* #### Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller('/')
|
|
10
|
+
* class MyCtrl {
|
|
11
|
+
* @Get('/')
|
|
12
|
+
* get(@HeaderParams() body: any) {
|
|
13
|
+
* console.log('Entire body', body);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* @Get('/')
|
|
17
|
+
* get(@HeaderParams('x-token') token: string) {
|
|
18
|
+
* console.log('token', id);
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param expression The path of the property to get.
|
|
24
|
+
* @param useType
|
|
25
|
+
* @decorator
|
|
26
|
+
* @operation
|
|
27
|
+
* @input
|
|
28
|
+
*/
|
|
29
|
+
export declare function HeaderParams(expression: string, useType: Type<any>): ParameterDecorator;
|
|
30
|
+
export declare function HeaderParams(expression: string): ParameterDecorator;
|
|
31
|
+
export declare function HeaderParams(useType: Type<any>): ParameterDecorator;
|
|
32
|
+
export declare function HeaderParams(options: Partial<ParamOptions>): ParameterDecorator;
|
|
33
|
+
export declare function HeaderParams(): ParameterDecorator;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locals return the value from [response.locals](http://expressjs.com/en/4x/api.html#res.locals) object.
|
|
3
|
+
*
|
|
4
|
+
* ::: tip
|
|
5
|
+
* Locals are generally used by express and third-party like templating engine to render a page/template.
|
|
6
|
+
* See [Templating](http://tsed.io/tutorials/templating.html) section for more details.
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* #### Example
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* * @Middleware()
|
|
13
|
+
* class LocalsMiddleware {
|
|
14
|
+
* use(@Locals() locals: any) {
|
|
15
|
+
* // set some on locals
|
|
16
|
+
* locals.user = "user"
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* @Controller('/')
|
|
21
|
+
* @UseBefore(LocalsMiddleware)
|
|
22
|
+
* class MyCtrl {
|
|
23
|
+
* @Get('/')
|
|
24
|
+
* @View('home.ejs') // will use locals and returned data to render the page
|
|
25
|
+
* get(@Locals('user') user: any) {
|
|
26
|
+
* console.log('user', user);
|
|
27
|
+
*
|
|
28
|
+
* return {
|
|
29
|
+
* description: 'Hello world'
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param expression The path of the property to get.
|
|
36
|
+
* @decorator
|
|
37
|
+
* @operation
|
|
38
|
+
* @input
|
|
39
|
+
* @response
|
|
40
|
+
*/
|
|
41
|
+
export declare function Locals(expression: string): ParameterDecorator;
|
|
42
|
+
export declare function Locals(): ParameterDecorator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DecoratorParameters } from "@tsed/core";
|
|
2
|
+
import { ParamMetadata } from "../domain/ParamMetadata";
|
|
3
|
+
/**
|
|
4
|
+
* Get the Param metadata. Use this decorator to compose your own decorator.
|
|
5
|
+
*
|
|
6
|
+
* @param fn
|
|
7
|
+
* @decorator
|
|
8
|
+
* @operation
|
|
9
|
+
* @input
|
|
10
|
+
*/
|
|
11
|
+
export declare function ParamFn(fn: (param: ParamMetadata, parameters: DecoratorParameters) => void): ParameterDecorator;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ParamOptions } from "../domain/ParamOptions";
|
|
3
|
+
/**
|
|
4
|
+
* PathParams return the value from [request.params](http://expressjs.com/en/4x/api.html#req.params) object.
|
|
5
|
+
*
|
|
6
|
+
* #### Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller('/')
|
|
10
|
+
* class MyCtrl {
|
|
11
|
+
* @Get('/')
|
|
12
|
+
* get(@PathParams() params: any) {
|
|
13
|
+
* console.log('Entire params', params);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* @Get('/')
|
|
17
|
+
* get(@PathParams('id') id: string) {
|
|
18
|
+
* console.log('ID', id);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* @Get('/')
|
|
22
|
+
* get(@PathParams({expression: 'id', useType: () => new MyCustomModel() }) id: string) {
|
|
23
|
+
* console.log('ID', id);
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
28
|
+
*
|
|
29
|
+
* @param expression The path of the property to get.
|
|
30
|
+
* @param useType The type of the class that to be used to deserialize the data.
|
|
31
|
+
* @decorator
|
|
32
|
+
* @operation
|
|
33
|
+
* @input
|
|
34
|
+
*/
|
|
35
|
+
export declare function PathParams(expression: string, useType: Type<any>): ParameterDecorator;
|
|
36
|
+
export declare function PathParams(expression: string): ParameterDecorator;
|
|
37
|
+
export declare function PathParams(useType: Type<any>): ParameterDecorator;
|
|
38
|
+
export declare function PathParams(options: Partial<ParamOptions>): ParameterDecorator;
|
|
39
|
+
export declare function PathParams(): ParameterDecorator;
|
|
40
|
+
/**
|
|
41
|
+
* RawPathParams return the raw value from [request.params](http://expressjs.com/en/4x/api.html#req.params) object.
|
|
42
|
+
*
|
|
43
|
+
* Any validation and transformation are performed on the value. Use [pipes](/docs/pipes.html) to validate and/or transform the value.
|
|
44
|
+
*
|
|
45
|
+
* #### Example
|
|
46
|
+
*
|
|
47
|
+
* ```typescript
|
|
48
|
+
* @Controller('/')
|
|
49
|
+
* class MyCtrl {
|
|
50
|
+
* @Get('/')
|
|
51
|
+
* get(@RawPathParams() params: string) {
|
|
52
|
+
* console.log('Entire params', params);
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* @Get('/')
|
|
56
|
+
* get(@RawPathParams('id') id: string) {
|
|
57
|
+
* console.log('ID', id);
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
62
|
+
*
|
|
63
|
+
* @param expression The path of the property to get.
|
|
64
|
+
* @decorator
|
|
65
|
+
* @operation
|
|
66
|
+
* @input
|
|
67
|
+
*/
|
|
68
|
+
export declare function RawPathParams(expression: string): ParameterDecorator;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ParamOptions } from "../domain/ParamOptions";
|
|
3
|
+
/**
|
|
4
|
+
* QueryParams return the value from [request.query](http://expressjs.com/en/4x/api.html#req.query) object.
|
|
5
|
+
*
|
|
6
|
+
* #### Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller('/')
|
|
10
|
+
* class MyCtrl {
|
|
11
|
+
* @Get('/')
|
|
12
|
+
* get(@QueryParams() query: any) {
|
|
13
|
+
* console.log('Entire query', query);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* @Get('/')
|
|
17
|
+
* get(@QueryParams('id') id: string) {
|
|
18
|
+
* console.log('ID', id);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* @Get('/')
|
|
22
|
+
* get(@QueryParams('user') user: User) { // with deserialization
|
|
23
|
+
* console.log('user', user);
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @Get('/')
|
|
27
|
+
* get(@QueryParams('users', User) users: User[]) { // with deserialization
|
|
28
|
+
* console.log('users', users);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
33
|
+
*
|
|
34
|
+
* @param expression The path of the property to get.
|
|
35
|
+
* @param useType The type of the class that to be used to deserialize the data.
|
|
36
|
+
* @decorator
|
|
37
|
+
* @operation
|
|
38
|
+
* @input
|
|
39
|
+
*/
|
|
40
|
+
export declare function QueryParams(expression: string, useType: Type<any>): ParameterDecorator;
|
|
41
|
+
export declare function QueryParams(expression: string): ParameterDecorator;
|
|
42
|
+
export declare function QueryParams(useType: Type<any>): ParameterDecorator;
|
|
43
|
+
export declare function QueryParams(options: Partial<ParamOptions>): ParameterDecorator;
|
|
44
|
+
export declare function QueryParams(): ParameterDecorator;
|
|
45
|
+
/**
|
|
46
|
+
* RawQueryParams return the value from [request.query](http://expressjs.com/en/4x/api.html#req.query) object.
|
|
47
|
+
*
|
|
48
|
+
* Any validation and transformation are performed on the value. Use [pipes](/docs/pipes.html) to validate and/or transform the value.
|
|
49
|
+
*
|
|
50
|
+
* #### Example
|
|
51
|
+
*
|
|
52
|
+
* ```typescript
|
|
53
|
+
* @Controller('/')
|
|
54
|
+
* class MyCtrl {
|
|
55
|
+
* @Get('/')
|
|
56
|
+
* get(@RawPathParams() params: any) {
|
|
57
|
+
* console.log('Entire params', params);
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* @Get('/')
|
|
61
|
+
* get(@RawPathParams('id') id: string) {
|
|
62
|
+
* console.log('ID', id);
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
67
|
+
*
|
|
68
|
+
* @param expression The path of the property to get.
|
|
69
|
+
* @decorator
|
|
70
|
+
* @operation
|
|
71
|
+
* @input
|
|
72
|
+
*/
|
|
73
|
+
export declare function RawQueryParams(expression: string): ParameterDecorator;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ParamOptions } from "../domain/ParamOptions";
|
|
2
|
+
/**
|
|
3
|
+
* Session return the value from [request.session](http://expressjs.com/en/4x/api.html#req.session) object.
|
|
4
|
+
*
|
|
5
|
+
* #### Example
|
|
6
|
+
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* @Controller('/')
|
|
9
|
+
* class MyCtrl {
|
|
10
|
+
* @Post('/')
|
|
11
|
+
* create(@Session() session: Express.Session) {
|
|
12
|
+
* console.log('Entire session', session);
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* @Post('/')
|
|
16
|
+
* create(@Session('id') id: string) {
|
|
17
|
+
* console.log('ID', id);
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* @Post('/') // Example to deserialize use from session
|
|
21
|
+
* create(@Session({expression: 'user', useConverter: true}) user: User) {
|
|
22
|
+
* console.log('user', user);
|
|
23
|
+
* console.log('instanceOf user', user instanceof User);
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
28
|
+
*
|
|
29
|
+
* @param expression The path of the property to get.
|
|
30
|
+
* @decorator
|
|
31
|
+
* @operation
|
|
32
|
+
* @input
|
|
33
|
+
*/
|
|
34
|
+
export declare function Session(expression: string): ParameterDecorator;
|
|
35
|
+
export declare function Session(options: Partial<ParamOptions>): ParameterDecorator;
|
|
36
|
+
export declare function Session(): ParameterDecorator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ParamOptions } from "../domain/ParamOptions";
|
|
2
|
+
/**
|
|
3
|
+
* Register a new param. It use the paramType to extract value and give it to the next pipe.
|
|
4
|
+
*
|
|
5
|
+
* Given options allow to enable or disable following pipes:
|
|
6
|
+
*
|
|
7
|
+
* - useType: Add extra type for the json mapper,
|
|
8
|
+
* - expression: Get property from the returned value by the previous pipe.
|
|
9
|
+
* - useValidation: Apply validation from the returned value by the previous pipe.
|
|
10
|
+
* - useConverter: Apply json mapper from the returned value by the previous pipe.
|
|
11
|
+
*
|
|
12
|
+
* @param options
|
|
13
|
+
* @decorator
|
|
14
|
+
* @operation
|
|
15
|
+
* @input
|
|
16
|
+
* @pipe
|
|
17
|
+
*/
|
|
18
|
+
export declare function UseParam(options: Partial<ParamOptions>): ParameterDecorator;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Since v6
|
|
21
|
+
*/
|
|
22
|
+
export declare function UseParam(paramType: string, options?: Partial<ParamOptions>): ParameterDecorator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { PipeMethods } from "../domain/ParamMetadata";
|
|
3
|
+
/**
|
|
4
|
+
* Register a Pipe to be used with the current decorated param.
|
|
5
|
+
*
|
|
6
|
+
* @param token
|
|
7
|
+
* @param options
|
|
8
|
+
* @decorator
|
|
9
|
+
* @operation
|
|
10
|
+
* @input
|
|
11
|
+
* @pipe
|
|
12
|
+
*/
|
|
13
|
+
export declare function UsePipe(token: Type<PipeMethods>, options?: any): ParameterDecorator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
/**
|
|
3
|
+
* Set the type of the item colllection.
|
|
4
|
+
*
|
|
5
|
+
* Prefer @@CollectionOf@@ usage.
|
|
6
|
+
*
|
|
7
|
+
* @param type
|
|
8
|
+
* @decorator
|
|
9
|
+
* @operation
|
|
10
|
+
* @input
|
|
11
|
+
* @alias CollectionOf
|
|
12
|
+
*/
|
|
13
|
+
export declare function UseType(type: any | Type<any>): import("@tsed/schema").CollectionOfChainedDecorators;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { JsonEntityStoreOptions, JsonParameterStore } from "@tsed/schema";
|
|
3
|
+
import { ParamOptions } from "./ParamOptions";
|
|
4
|
+
export interface PipeMethods<T = any, R = any> {
|
|
5
|
+
transform(value: T, metadata: ParamMetadata): R;
|
|
6
|
+
}
|
|
7
|
+
export declare type ParamConstructorOptions = JsonEntityStoreOptions & ParamOptions;
|
|
8
|
+
export declare class ParamMetadata extends JsonParameterStore implements ParamConstructorOptions {
|
|
9
|
+
expression: string;
|
|
10
|
+
dataPath: string;
|
|
11
|
+
paramType: string;
|
|
12
|
+
pipes: Type<PipeMethods>[];
|
|
13
|
+
constructor(options: ParamConstructorOptions);
|
|
14
|
+
get key(): string;
|
|
15
|
+
static get(target: Type<any>, propertyKey: string | symbol, index: number): ParamMetadata;
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare enum ParamTypes {
|
|
2
|
+
$CTX = "$CTX",
|
|
3
|
+
BODY = "BODY",
|
|
4
|
+
PATH = "PATH",
|
|
5
|
+
QUERY = "QUERY",
|
|
6
|
+
HEADER = "HEADER",
|
|
7
|
+
RAW_BODY = "RAW_BODY",
|
|
8
|
+
COOKIES = "COOKIES",
|
|
9
|
+
LOCALS = "LOCALS",
|
|
10
|
+
SESSION = "SESSION",
|
|
11
|
+
FILES = "FILES",
|
|
12
|
+
NEXT_FN = "NEXT_FN",
|
|
13
|
+
ERR = "ERR",
|
|
14
|
+
REQUEST = "REQUEST",
|
|
15
|
+
PLATFORM_REQUEST = "PLATFORM_REQUEST",
|
|
16
|
+
NODE_REQUEST = "NODE_REQUEST",
|
|
17
|
+
RESPONSE = "RESPONSE",
|
|
18
|
+
PLATFORM_RESPONSE = "PLATFORM_RESPONSE",
|
|
19
|
+
NODE_RESPONSE = "NODE_RESPONSE",
|
|
20
|
+
RESPONSE_DATA = "RESPONSE_DATA",
|
|
21
|
+
ENDPOINT_INFO = "ENDPOINT_INFO",
|
|
22
|
+
RES = "RES",
|
|
23
|
+
REQ = "REQ"
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BadRequest } from "@tsed/exceptions";
|
|
2
|
+
import { ParamMetadata } from "../domain/ParamMetadata";
|
|
3
|
+
export declare class ParamValidationError extends BadRequest {
|
|
4
|
+
name: string;
|
|
5
|
+
dataPath: string;
|
|
6
|
+
requestType: string;
|
|
7
|
+
static from(metadata: ParamMetadata, origin?: any): any;
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from "./utils/mapParamsOptions";
|
|
2
|
+
export * from "./domain/ParamMetadata";
|
|
3
|
+
export * from "./domain/ParamOptions";
|
|
4
|
+
export * from "./domain/ParamTypes";
|
|
5
|
+
export * from "./pipes/ParseExpressionPipe";
|
|
6
|
+
export * from "./pipes/DeserializerPipe";
|
|
7
|
+
export * from "./pipes/ValidationPipe";
|
|
8
|
+
export * from "./builder/PlatformParams";
|
|
9
|
+
export * from "./errors/RequiredValidationError";
|
|
10
|
+
export * from "./errors/ValidationError";
|
|
11
|
+
export * from "./errors/ParamValidationError";
|
|
12
|
+
export * from "./decorators/context";
|
|
13
|
+
export * from "./decorators/bodyParams";
|
|
14
|
+
export * from "./decorators/usePipe";
|
|
15
|
+
export * from "./decorators/useParam";
|
|
16
|
+
export * from "./decorators/useParamType";
|
|
17
|
+
export * from "./decorators/useType";
|
|
18
|
+
export * from "./decorators/useValidation";
|
|
19
|
+
export * from "./decorators/useDeserialization";
|
|
20
|
+
export * from "./decorators/useParamExpression";
|
|
21
|
+
export * from "./decorators/useParamType";
|
|
22
|
+
export * from "./decorators/headerParams";
|
|
23
|
+
export * from "./decorators/cookies";
|
|
24
|
+
export * from "./decorators/locals";
|
|
25
|
+
export * from "./decorators/pathParams";
|
|
26
|
+
export * from "./decorators/queryParams";
|
|
27
|
+
export * from "./decorators/session";
|
|
28
|
+
export * from "./decorators/paramFn";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectorService } from "@tsed/di";
|
|
2
|
+
import { PipeMethods, ParamMetadata } from "../domain/ParamMetadata";
|
|
3
|
+
export declare class ValidationPipe implements PipeMethods {
|
|
4
|
+
private validator;
|
|
5
|
+
constructor(injector: InjectorService);
|
|
6
|
+
coerceTypes(value: any, metadata: ParamMetadata): any;
|
|
7
|
+
skip(value: any, metadata: ParamMetadata): boolean;
|
|
8
|
+
transform(value: any, metadata: ParamMetadata): Promise<any>;
|
|
9
|
+
protected checkIsRequired(value: any, metadata: ParamMetadata): boolean;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-params",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.89.0",
|
|
4
4
|
"description": "Params module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
|
-
"typings": "./lib/index.d.ts",
|
|
7
|
+
"main": "./lib/cjs/index.js",
|
|
8
|
+
"typings": "./lib/types/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"import": "./lib/esm/index.js",
|
|
12
|
+
"require": "./lib/cjs/index.js",
|
|
13
|
+
"default": "./lib/esm/index.js"
|
|
12
14
|
},
|
|
13
15
|
"scripts": {
|
|
14
|
-
"build": "
|
|
16
|
+
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
|
+
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
|
+
"build:esm": "tsc --build tsconfig.compile.esm.json"
|
|
15
19
|
},
|
|
16
20
|
"dependencies": {
|
|
17
21
|
"tslib": "2.2.0"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@tsed/core": "6.
|
|
21
|
-
"@tsed/di": "6.
|
|
22
|
-
"@tsed/exceptions": "6.
|
|
23
|
-
"@tsed/json-mapper": "6.
|
|
24
|
-
"@tsed/schema": "6.
|
|
24
|
+
"@tsed/core": "6.89.0",
|
|
25
|
+
"@tsed/di": "6.89.0",
|
|
26
|
+
"@tsed/exceptions": "6.89.0",
|
|
27
|
+
"@tsed/json-mapper": "6.89.0",
|
|
28
|
+
"@tsed/schema": "6.89.0"
|
|
25
29
|
},
|
|
26
30
|
"peerDependencies": {
|
|
27
|
-
"@tsed/core": "^6.
|
|
28
|
-
"@tsed/di": "^6.
|
|
29
|
-
"@tsed/exceptions": "^6.
|
|
30
|
-
"@tsed/json-mapper": "^6.
|
|
31
|
-
"@tsed/schema": "^6.
|
|
31
|
+
"@tsed/core": "^6.89.0",
|
|
32
|
+
"@tsed/di": "^6.89.0",
|
|
33
|
+
"@tsed/exceptions": "^6.89.0",
|
|
34
|
+
"@tsed/json-mapper": "^6.89.0",
|
|
35
|
+
"@tsed/schema": "^6.89.0"
|
|
32
36
|
},
|
|
33
37
|
"repository": "https://github.com/tsedio/tsed",
|
|
34
38
|
"bugs": {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.compile.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"module": "ES2020",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "./lib/esm",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./lib/types"
|
|
10
|
+
},
|
|
11
|
+
"exclude": [
|
|
12
|
+
"node_modules",
|
|
13
|
+
"test",
|
|
14
|
+
"lib",
|
|
15
|
+
"benchmark",
|
|
16
|
+
"coverage",
|
|
17
|
+
"spec",
|
|
18
|
+
"**/*.benchmark.ts",
|
|
19
|
+
"**/*.spec.ts",
|
|
20
|
+
"keys",
|
|
21
|
+
"jest.config.js"
|
|
22
|
+
]
|
|
23
|
+
}
|