@tsed/platform-params 6.87.2 → 6.90.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.
Files changed (174) hide show
  1. package/lib/{builder → cjs/builder}/PlatformParams.d.ts +0 -0
  2. package/lib/cjs/builder/PlatformParams.js +79 -0
  3. package/lib/cjs/builder/PlatformParams.js.map +1 -0
  4. package/lib/{decorators → cjs/decorators}/bodyParams.d.ts +0 -0
  5. package/lib/cjs/decorators/bodyParams.js +53 -0
  6. package/lib/cjs/decorators/bodyParams.js.map +1 -0
  7. package/lib/{decorators → cjs/decorators}/context.d.ts +0 -0
  8. package/lib/cjs/decorators/context.js +19 -0
  9. package/lib/cjs/decorators/context.js.map +1 -0
  10. package/lib/{decorators → cjs/decorators}/cookies.d.ts +0 -0
  11. package/lib/cjs/decorators/cookies.js +24 -0
  12. package/lib/cjs/decorators/cookies.js.map +1 -0
  13. package/lib/{decorators → cjs/decorators}/headerParams.d.ts +0 -0
  14. package/lib/cjs/decorators/headerParams.js +19 -0
  15. package/lib/cjs/decorators/headerParams.js.map +1 -0
  16. package/lib/{decorators → cjs/decorators}/locals.d.ts +0 -0
  17. package/lib/cjs/decorators/locals.js +19 -0
  18. package/lib/cjs/decorators/locals.js.map +1 -0
  19. package/lib/{decorators → cjs/decorators}/paramFn.d.ts +0 -0
  20. package/lib/cjs/decorators/paramFn.js +22 -0
  21. package/lib/cjs/decorators/paramFn.js.map +1 -0
  22. package/lib/{decorators → cjs/decorators}/pathParams.d.ts +0 -0
  23. package/lib/cjs/decorators/pathParams.js +55 -0
  24. package/lib/cjs/decorators/pathParams.js.map +1 -0
  25. package/lib/{decorators → cjs/decorators}/queryParams.d.ts +0 -0
  26. package/lib/cjs/decorators/queryParams.js +55 -0
  27. package/lib/cjs/decorators/queryParams.js.map +1 -0
  28. package/lib/{decorators → cjs/decorators}/session.d.ts +0 -0
  29. package/lib/cjs/decorators/session.js +19 -0
  30. package/lib/cjs/decorators/session.js.map +1 -0
  31. package/lib/{decorators → cjs/decorators}/useDeserialization.d.ts +0 -0
  32. package/lib/cjs/decorators/useDeserialization.js +18 -0
  33. package/lib/cjs/decorators/useDeserialization.js.map +1 -0
  34. package/lib/{decorators → cjs/decorators}/useParam.d.ts +0 -0
  35. package/lib/cjs/decorators/useParam.js +38 -0
  36. package/lib/cjs/decorators/useParam.js.map +1 -0
  37. package/lib/{decorators → cjs/decorators}/useParamExpression.d.ts +0 -0
  38. package/lib/cjs/decorators/useParamExpression.js +20 -0
  39. package/lib/cjs/decorators/useParamExpression.js.map +1 -0
  40. package/lib/{decorators → cjs/decorators}/useParamType.d.ts +0 -0
  41. package/lib/cjs/decorators/useParamType.js +26 -0
  42. package/lib/cjs/decorators/useParamType.js.map +1 -0
  43. package/lib/{decorators → cjs/decorators}/usePipe.d.ts +0 -0
  44. package/lib/cjs/decorators/usePipe.js +22 -0
  45. package/lib/cjs/decorators/usePipe.js.map +1 -0
  46. package/lib/{decorators → cjs/decorators}/useType.d.ts +0 -0
  47. package/lib/cjs/decorators/useType.js +20 -0
  48. package/lib/cjs/decorators/useType.js.map +1 -0
  49. package/lib/{decorators → cjs/decorators}/useValidation.d.ts +0 -0
  50. package/lib/cjs/decorators/useValidation.js +22 -0
  51. package/lib/cjs/decorators/useValidation.js.map +1 -0
  52. package/lib/{domain → cjs/domain}/ParamMetadata.d.ts +0 -0
  53. package/lib/cjs/domain/ParamMetadata.js +34 -0
  54. package/lib/cjs/domain/ParamMetadata.js.map +1 -0
  55. package/lib/{domain → cjs/domain}/ParamOptions.d.ts +0 -0
  56. package/lib/cjs/domain/ParamOptions.js +3 -0
  57. package/lib/cjs/domain/ParamOptions.js.map +1 -0
  58. package/lib/{domain → cjs/domain}/ParamTypes.d.ts +0 -0
  59. package/lib/cjs/domain/ParamTypes.js +30 -0
  60. package/lib/cjs/domain/ParamTypes.js.map +1 -0
  61. package/lib/{errors → cjs/errors}/ParamValidationError.d.ts +0 -0
  62. package/lib/cjs/errors/ParamValidationError.js +29 -0
  63. package/lib/cjs/errors/ParamValidationError.js.map +1 -0
  64. package/lib/{errors → cjs/errors}/RequiredValidationError.d.ts +0 -1
  65. package/lib/cjs/errors/RequiredValidationError.js +32 -0
  66. package/lib/cjs/errors/RequiredValidationError.js.map +1 -0
  67. package/lib/{errors → cjs/errors}/ValidationError.d.ts +0 -0
  68. package/lib/cjs/errors/ValidationError.js +13 -0
  69. package/lib/cjs/errors/ValidationError.js.map +1 -0
  70. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  71. package/lib/cjs/index.js +37 -0
  72. package/lib/cjs/index.js.map +1 -0
  73. package/lib/{pipes → cjs/pipes}/DeserializerPipe.d.ts +0 -0
  74. package/lib/cjs/pipes/DeserializerPipe.js +30 -0
  75. package/lib/cjs/pipes/DeserializerPipe.js.map +1 -0
  76. package/lib/{pipes → cjs/pipes}/ParseExpressionPipe.d.ts +0 -0
  77. package/lib/cjs/pipes/ParseExpressionPipe.js +24 -0
  78. package/lib/cjs/pipes/ParseExpressionPipe.js.map +1 -0
  79. package/lib/{pipes → cjs/pipes}/ValidationPipe.d.ts +0 -0
  80. package/lib/cjs/pipes/ValidationPipe.js +80 -0
  81. package/lib/cjs/pipes/ValidationPipe.js.map +1 -0
  82. package/lib/{utils → cjs/utils}/mapParamsOptions.d.ts +0 -0
  83. package/lib/cjs/utils/mapParamsOptions.js +30 -0
  84. package/lib/cjs/utils/mapParamsOptions.js.map +1 -0
  85. package/lib/esm/builder/PlatformParams.js +76 -0
  86. package/lib/esm/builder/PlatformParams.js.map +1 -0
  87. package/lib/esm/decorators/bodyParams.js +48 -0
  88. package/lib/esm/decorators/bodyParams.js.map +1 -0
  89. package/lib/esm/decorators/context.js +15 -0
  90. package/lib/esm/decorators/context.js.map +1 -0
  91. package/lib/esm/decorators/cookies.js +19 -0
  92. package/lib/esm/decorators/cookies.js.map +1 -0
  93. package/lib/esm/decorators/headerParams.js +15 -0
  94. package/lib/esm/decorators/headerParams.js.map +1 -0
  95. package/lib/esm/decorators/locals.js +15 -0
  96. package/lib/esm/decorators/locals.js.map +1 -0
  97. package/lib/esm/decorators/paramFn.js +18 -0
  98. package/lib/esm/decorators/paramFn.js.map +1 -0
  99. package/lib/esm/decorators/pathParams.js +50 -0
  100. package/lib/esm/decorators/pathParams.js.map +1 -0
  101. package/lib/esm/decorators/queryParams.js +50 -0
  102. package/lib/esm/decorators/queryParams.js.map +1 -0
  103. package/lib/esm/decorators/session.js +15 -0
  104. package/lib/esm/decorators/session.js.map +1 -0
  105. package/lib/esm/decorators/useDeserialization.js +14 -0
  106. package/lib/esm/decorators/useDeserialization.js.map +1 -0
  107. package/lib/esm/decorators/useParam.js +34 -0
  108. package/lib/esm/decorators/useParam.js.map +1 -0
  109. package/lib/esm/decorators/useParamExpression.js +16 -0
  110. package/lib/esm/decorators/useParamExpression.js.map +1 -0
  111. package/lib/esm/decorators/useParamType.js +22 -0
  112. package/lib/esm/decorators/useParamType.js.map +1 -0
  113. package/lib/esm/decorators/usePipe.js +18 -0
  114. package/lib/esm/decorators/usePipe.js.map +1 -0
  115. package/lib/esm/decorators/useType.js +16 -0
  116. package/lib/esm/decorators/useType.js.map +1 -0
  117. package/lib/esm/decorators/useValidation.js +18 -0
  118. package/lib/esm/decorators/useValidation.js.map +1 -0
  119. package/lib/esm/domain/ParamMetadata.js +31 -0
  120. package/lib/esm/domain/ParamMetadata.js.map +1 -0
  121. package/lib/esm/domain/ParamOptions.js +2 -0
  122. package/lib/esm/domain/ParamOptions.js.map +1 -0
  123. package/lib/esm/domain/ParamTypes.js +27 -0
  124. package/lib/esm/domain/ParamTypes.js.map +1 -0
  125. package/lib/esm/errors/ParamValidationError.js +25 -0
  126. package/lib/esm/errors/ParamValidationError.js.map +1 -0
  127. package/lib/esm/errors/RequiredValidationError.js +28 -0
  128. package/lib/esm/errors/RequiredValidationError.js.map +1 -0
  129. package/lib/esm/errors/ValidationError.js +9 -0
  130. package/lib/esm/errors/ValidationError.js.map +1 -0
  131. package/lib/esm/index.js +34 -0
  132. package/lib/esm/index.js.map +1 -0
  133. package/lib/esm/pipes/DeserializerPipe.js +27 -0
  134. package/lib/esm/pipes/DeserializerPipe.js.map +1 -0
  135. package/lib/esm/pipes/ParseExpressionPipe.js +21 -0
  136. package/lib/esm/pipes/ParseExpressionPipe.js.map +1 -0
  137. package/lib/esm/pipes/ValidationPipe.js +77 -0
  138. package/lib/esm/pipes/ValidationPipe.js.map +1 -0
  139. package/lib/esm/utils/mapParamsOptions.js +26 -0
  140. package/lib/esm/utils/mapParamsOptions.js.map +1 -0
  141. package/lib/types/builder/PlatformParams.d.ts +23 -0
  142. package/lib/types/decorators/bodyParams.d.ts +64 -0
  143. package/lib/types/decorators/context.d.ts +59 -0
  144. package/lib/types/decorators/cookies.d.ts +81 -0
  145. package/lib/types/decorators/headerParams.d.ts +33 -0
  146. package/lib/types/decorators/locals.d.ts +42 -0
  147. package/lib/types/decorators/paramFn.d.ts +11 -0
  148. package/lib/types/decorators/pathParams.d.ts +68 -0
  149. package/lib/types/decorators/queryParams.d.ts +73 -0
  150. package/lib/types/decorators/session.d.ts +36 -0
  151. package/lib/types/decorators/useDeserialization.d.ts +9 -0
  152. package/lib/types/decorators/useParam.d.ts +22 -0
  153. package/lib/types/decorators/useParamExpression.d.ts +10 -0
  154. package/lib/types/decorators/useParamType.d.ts +10 -0
  155. package/lib/types/decorators/usePipe.d.ts +13 -0
  156. package/lib/types/decorators/useType.d.ts +13 -0
  157. package/lib/types/decorators/useValidation.d.ts +9 -0
  158. package/lib/types/domain/ParamMetadata.d.ts +16 -0
  159. package/lib/types/domain/ParamOptions.d.ts +10 -0
  160. package/lib/types/domain/ParamTypes.d.ts +24 -0
  161. package/lib/types/errors/ParamValidationError.d.ts +8 -0
  162. package/lib/types/errors/RequiredValidationError.d.ts +6 -0
  163. package/lib/types/errors/ValidationError.d.ts +6 -0
  164. package/lib/types/index.d.ts +28 -0
  165. package/lib/types/pipes/DeserializerPipe.d.ts +5 -0
  166. package/lib/types/pipes/ParseExpressionPipe.d.ts +5 -0
  167. package/lib/types/pipes/ValidationPipe.d.ts +10 -0
  168. package/lib/types/utils/mapParamsOptions.d.ts +5 -0
  169. package/package.json +20 -16
  170. package/tsconfig.compile.esm.json +23 -0
  171. package/lib/index.js +0 -807
  172. package/lib/index.js.map +0 -1
  173. package/lib/index.modern.js +0 -788
  174. 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,9 @@
1
+ /**
2
+ * Use JsonMapper to deserialize the data.
3
+ *
4
+ * @decorator
5
+ * @operation
6
+ * @input
7
+ * @pipe
8
+ */
9
+ export declare function UseDeserialization(options?: any): 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,10 @@
1
+ /**
2
+ * Get data from a path inside the given object
3
+ *
4
+ * @param expression
5
+ * @decorator
6
+ * @operation
7
+ * @input
8
+ * @pipe
9
+ */
10
+ export declare function UseParamExpression(expression?: string): ParameterDecorator;
@@ -0,0 +1,10 @@
1
+ import { ParamOptions } from "../domain/ParamOptions";
2
+ /**
3
+ * Get the object from request (like body, params, query, etc...).
4
+ *
5
+ * @decorator
6
+ * @operation
7
+ * @input
8
+ * @pipe
9
+ */
10
+ export declare function UseParamType(options: ParamOptions): any;
@@ -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,9 @@
1
+ /**
2
+ * Enable validation on the decoratored parameter.
3
+ *
4
+ * @decorator
5
+ * @operation
6
+ * @input
7
+ * @pipe
8
+ */
9
+ export declare function UseValidation(): ParameterDecorator;
@@ -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,10 @@
1
+ import { Type } from "@tsed/core";
2
+ export interface ParamOptions<T = any> {
3
+ dataPath: string;
4
+ paramType: string;
5
+ expression?: string;
6
+ useType?: Type<T>;
7
+ useConverter?: boolean;
8
+ useValidation?: boolean;
9
+ [key: string]: any;
10
+ }
@@ -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,6 @@
1
+ import { ParamMetadata } from "../domain/ParamMetadata";
2
+ import { ValidationError } from "./ValidationError";
3
+ export declare class RequiredValidationError extends ValidationError {
4
+ name: string;
5
+ static from(metadata: ParamMetadata): RequiredValidationError;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { BadRequest } from "@tsed/exceptions";
2
+ export declare class ValidationError extends BadRequest {
3
+ name: string;
4
+ errors: any[];
5
+ constructor(message: string, errors?: any[]);
6
+ }
@@ -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,5 @@
1
+ import { ParamMetadata, PipeMethods } from "../domain/ParamMetadata";
2
+ export declare class DeserializerPipe implements PipeMethods {
3
+ private settings;
4
+ transform(value: any, param: ParamMetadata): any;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { PipeMethods, ParamMetadata } from "../domain/ParamMetadata";
2
+ import type { ArgScope } from "../builder/PlatformParams";
3
+ export declare class ParseExpressionPipe implements PipeMethods {
4
+ transform(scope: ArgScope, param: ParamMetadata): any;
5
+ }
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ import { ParamOptions } from "../domain/ParamOptions";
2
+ /**
3
+ * @ignore
4
+ */
5
+ export declare function mapParamsOptions(args: any[]): Partial<ParamOptions<any>>;
package/package.json CHANGED
@@ -1,34 +1,38 @@
1
1
  {
2
2
  "name": "@tsed/platform-params",
3
- "version": "6.87.2",
3
+ "version": "6.90.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
- "require": "./lib/index.js",
11
- "default": "./lib/index.modern.js"
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": "microbundle --target node --no-compress --format modern,cjs --tsconfig ./tsconfig.compile.json"
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.87.2",
21
- "@tsed/di": "6.87.2",
22
- "@tsed/exceptions": "6.87.2",
23
- "@tsed/json-mapper": "6.87.2",
24
- "@tsed/schema": "6.87.2"
24
+ "@tsed/core": "6.90.0",
25
+ "@tsed/di": "6.90.0",
26
+ "@tsed/exceptions": "6.90.0",
27
+ "@tsed/json-mapper": "6.90.0",
28
+ "@tsed/schema": "6.90.0"
25
29
  },
26
30
  "peerDependencies": {
27
- "@tsed/core": "^6.87.2",
28
- "@tsed/di": "^6.87.2",
29
- "@tsed/exceptions": "^6.87.2",
30
- "@tsed/json-mapper": "^6.87.2",
31
- "@tsed/schema": "^6.87.2"
31
+ "@tsed/core": "^6.90.0",
32
+ "@tsed/di": "^6.90.0",
33
+ "@tsed/exceptions": "^6.90.0",
34
+ "@tsed/json-mapper": "^6.90.0",
35
+ "@tsed/schema": "^6.90.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
+ }