@tsed/platform-params 8.0.0-alpha.5 → 8.0.0-alpha.6

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 (90) hide show
  1. package/package.json +15 -16
  2. package/lib/cjs/builder/PlatformParams.js +0 -75
  3. package/lib/cjs/builder/PlatformParams.js.map +0 -1
  4. package/lib/cjs/decorators/bodyParams.js +0 -28
  5. package/lib/cjs/decorators/bodyParams.js.map +0 -1
  6. package/lib/cjs/decorators/context.js +0 -18
  7. package/lib/cjs/decorators/context.js.map +0 -1
  8. package/lib/cjs/decorators/cookies.js +0 -23
  9. package/lib/cjs/decorators/cookies.js.map +0 -1
  10. package/lib/cjs/decorators/headerParams.js +0 -18
  11. package/lib/cjs/decorators/headerParams.js.map +0 -1
  12. package/lib/cjs/decorators/locals.js +0 -18
  13. package/lib/cjs/decorators/locals.js.map +0 -1
  14. package/lib/cjs/decorators/paramFn.js +0 -17
  15. package/lib/cjs/decorators/paramFn.js.map +0 -1
  16. package/lib/cjs/decorators/pathParams.js +0 -28
  17. package/lib/cjs/decorators/pathParams.js.map +0 -1
  18. package/lib/cjs/decorators/queryParams.js +0 -28
  19. package/lib/cjs/decorators/queryParams.js.map +0 -1
  20. package/lib/cjs/decorators/session.js +0 -18
  21. package/lib/cjs/decorators/session.js.map +0 -1
  22. package/lib/cjs/decorators/useDeserialization.js +0 -18
  23. package/lib/cjs/decorators/useDeserialization.js.map +0 -1
  24. package/lib/cjs/decorators/useParam.js +0 -38
  25. package/lib/cjs/decorators/useParam.js.map +0 -1
  26. package/lib/cjs/decorators/useParamExpression.js +0 -20
  27. package/lib/cjs/decorators/useParamExpression.js.map +0 -1
  28. package/lib/cjs/decorators/useParamType.js +0 -31
  29. package/lib/cjs/decorators/useParamType.js.map +0 -1
  30. package/lib/cjs/decorators/usePipe.js +0 -22
  31. package/lib/cjs/decorators/usePipe.js.map +0 -1
  32. package/lib/cjs/decorators/useType.js +0 -34
  33. package/lib/cjs/decorators/useType.js.map +0 -1
  34. package/lib/cjs/decorators/useValidation.js +0 -22
  35. package/lib/cjs/decorators/useValidation.js.map +0 -1
  36. package/lib/cjs/domain/ParamMetadata.js +0 -6
  37. package/lib/cjs/domain/ParamMetadata.js.map +0 -1
  38. package/lib/cjs/domain/ParamOptions.js +0 -3
  39. package/lib/cjs/domain/ParamOptions.js.map +0 -1
  40. package/lib/cjs/domain/ParamTypes.js +0 -40
  41. package/lib/cjs/domain/ParamTypes.js.map +0 -1
  42. package/lib/cjs/errors/ParamValidationError.js +0 -36
  43. package/lib/cjs/errors/ParamValidationError.js.map +0 -1
  44. package/lib/cjs/errors/RequiredValidationError.js +0 -32
  45. package/lib/cjs/errors/RequiredValidationError.js.map +0 -1
  46. package/lib/cjs/errors/ValidationError.js +0 -13
  47. package/lib/cjs/errors/ValidationError.js.map +0 -1
  48. package/lib/cjs/exports.js +0 -3
  49. package/lib/cjs/exports.js.map +0 -1
  50. package/lib/cjs/index.js +0 -35
  51. package/lib/cjs/index.js.map +0 -1
  52. package/lib/cjs/package.json +0 -3
  53. package/lib/cjs/pipes/DeserializerPipe.js +0 -21
  54. package/lib/cjs/pipes/DeserializerPipe.js.map +0 -1
  55. package/lib/cjs/pipes/ParseExpressionPipe.js +0 -32
  56. package/lib/cjs/pipes/ParseExpressionPipe.js.map +0 -1
  57. package/lib/cjs/pipes/ValidationPipe.js +0 -80
  58. package/lib/cjs/pipes/ValidationPipe.js.map +0 -1
  59. package/lib/cjs/utils/mapParamsOptions.js +0 -32
  60. package/lib/cjs/utils/mapParamsOptions.js.map +0 -1
  61. package/lib/esm/package.json +0 -3
  62. package/lib/types-esm/builder/PlatformParams.d.ts +0 -25
  63. package/lib/types-esm/decorators/bodyParams.d.ts +0 -66
  64. package/lib/types-esm/decorators/context.d.ts +0 -53
  65. package/lib/types-esm/decorators/cookies.d.ts +0 -81
  66. package/lib/types-esm/decorators/headerParams.d.ts +0 -33
  67. package/lib/types-esm/decorators/locals.d.ts +0 -42
  68. package/lib/types-esm/decorators/paramFn.d.ts +0 -11
  69. package/lib/types-esm/decorators/pathParams.d.ts +0 -70
  70. package/lib/types-esm/decorators/queryParams.d.ts +0 -75
  71. package/lib/types-esm/decorators/session.d.ts +0 -36
  72. package/lib/types-esm/decorators/useDeserialization.d.ts +0 -9
  73. package/lib/types-esm/decorators/useParam.d.ts +0 -18
  74. package/lib/types-esm/decorators/useParamExpression.d.ts +0 -10
  75. package/lib/types-esm/decorators/useParamType.d.ts +0 -10
  76. package/lib/types-esm/decorators/usePipe.d.ts +0 -13
  77. package/lib/types-esm/decorators/useType.d.ts +0 -13
  78. package/lib/types-esm/decorators/useValidation.d.ts +0 -9
  79. package/lib/types-esm/domain/ParamMetadata.d.ts +0 -1
  80. package/lib/types-esm/domain/ParamOptions.d.ts +0 -10
  81. package/lib/types-esm/domain/ParamTypes.d.ts +0 -25
  82. package/lib/types-esm/errors/ParamValidationError.d.ts +0 -8
  83. package/lib/types-esm/errors/RequiredValidationError.d.ts +0 -6
  84. package/lib/types-esm/errors/ValidationError.d.ts +0 -6
  85. package/lib/types-esm/exports.d.ts +0 -1
  86. package/lib/types-esm/index.d.ts +0 -31
  87. package/lib/types-esm/pipes/DeserializerPipe.d.ts +0 -4
  88. package/lib/types-esm/pipes/ParseExpressionPipe.d.ts +0 -6
  89. package/lib/types-esm/pipes/ValidationPipe.d.ts +0 -12
  90. package/lib/types-esm/utils/mapParamsOptions.d.ts +0 -5
@@ -1,42 +0,0 @@
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;
@@ -1,11 +0,0 @@
1
- import { DecoratorParameters } from "@tsed/core";
2
- import { JsonParameterStore } from "@tsed/schema";
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: JsonParameterStore, parameters: DecoratorParameters) => void): ParameterDecorator;
@@ -1,70 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { ParamOptions } from "../domain/ParamOptions.js";
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/json-mapper.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/json-mapper.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;
69
- export declare function RawPathParams(options: Partial<ParamOptions>): ParameterDecorator;
70
- export declare function RawPathParams(): ParameterDecorator;
@@ -1,75 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { ParamOptions } from "../domain/ParamOptions.js";
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/json-mapper.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/json-mapper.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;
74
- export declare function RawQueryParams(options: Partial<ParamOptions>): ParameterDecorator;
75
- export declare function RawQueryParams(): ParameterDecorator;
@@ -1,36 +0,0 @@
1
- import { ParamOptions } from "../domain/ParamOptions.js";
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', useMapper: 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/json-mapper.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;
@@ -1,9 +0,0 @@
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;
@@ -1,18 +0,0 @@
1
- import { ParamOptions } from "../domain/ParamOptions.js";
2
- /**
3
- * Register a new param. It uses 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
- * - useMapper: 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;
@@ -1,10 +0,0 @@
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;
@@ -1,10 +0,0 @@
1
- import { ParamOptions } from "../domain/ParamOptions.js";
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;
@@ -1,13 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { PipeMethods } from "@tsed/schema";
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;
@@ -1,13 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- /**
3
- * Set the type of the item collection.
4
- *
5
- * Prefer @@CollectionOf@@ usage.
6
- *
7
- * @param useType
8
- * @decorator
9
- * @operation
10
- * @input
11
- * @alias CollectionOf
12
- */
13
- export declare function UseType(useType: undefined | any | Type<any>): ParameterDecorator;
@@ -1,9 +0,0 @@
1
- /**
2
- * Enable validation on the decoratored parameter.
3
- *
4
- * @decorator
5
- * @operation
6
- * @input
7
- * @pipe
8
- */
9
- export declare function UseValidation(): ParameterDecorator;
@@ -1 +0,0 @@
1
- export { ParamMetadata } from "@tsed/schema";
@@ -1,10 +0,0 @@
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
- useMapper?: boolean;
8
- useValidation?: boolean;
9
- [key: string]: any;
10
- }
@@ -1,25 +0,0 @@
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
- }
25
- export declare const PARAM_TYPES_DATA_PATH: Record<string, string>;
@@ -1,8 +0,0 @@
1
- import { BadRequest } from "@tsed/exceptions";
2
- import { JsonParameterStore } from "@tsed/schema";
3
- export declare class ParamValidationError extends BadRequest {
4
- name: string;
5
- dataPath: string;
6
- requestType: string;
7
- static from(metadata: JsonParameterStore, origin?: any): any;
8
- }
@@ -1,6 +0,0 @@
1
- import { ValidationError } from "./ValidationError.js";
2
- import { JsonParameterStore } from "@tsed/schema";
3
- export declare class RequiredValidationError extends ValidationError {
4
- name: string;
5
- static from(metadata: JsonParameterStore): RequiredValidationError;
6
- }
@@ -1,6 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { PipeMethods } from "@tsed/schema";
@@ -1,31 +0,0 @@
1
- /**
2
- * @file Automatically generated by @tsed/barrels.
3
- */
4
- export * from "./builder/PlatformParams.js";
5
- export * from "./decorators/bodyParams.js";
6
- export * from "./decorators/context.js";
7
- export * from "./decorators/cookies.js";
8
- export * from "./decorators/headerParams.js";
9
- export * from "./decorators/locals.js";
10
- export * from "./decorators/paramFn.js";
11
- export * from "./decorators/pathParams.js";
12
- export * from "./decorators/queryParams.js";
13
- export * from "./decorators/session.js";
14
- export * from "./decorators/useDeserialization.js";
15
- export * from "./decorators/useParam.js";
16
- export * from "./decorators/useParamExpression.js";
17
- export * from "./decorators/useParamType.js";
18
- export * from "./decorators/usePipe.js";
19
- export * from "./decorators/useType.js";
20
- export * from "./decorators/useValidation.js";
21
- export * from "./domain/ParamMetadata.js";
22
- export * from "./domain/ParamOptions.js";
23
- export * from "./domain/ParamTypes.js";
24
- export * from "./errors/ParamValidationError.js";
25
- export * from "./errors/RequiredValidationError.js";
26
- export * from "./errors/ValidationError.js";
27
- export * from "./exports.js";
28
- export * from "./pipes/DeserializerPipe.js";
29
- export * from "./pipes/ParseExpressionPipe.js";
30
- export * from "./pipes/ValidationPipe.js";
31
- export * from "./utils/mapParamsOptions.js";
@@ -1,4 +0,0 @@
1
- import { JsonParameterStore, PipeMethods } from "@tsed/schema";
2
- export declare class DeserializerPipe implements PipeMethods {
3
- transform(value: any, param: JsonParameterStore): any;
4
- }
@@ -1,6 +0,0 @@
1
- import { JsonParameterStore, PipeMethods } from "@tsed/schema";
2
- import { PlatformParamsScope } from "../builder/PlatformParams.js";
3
- export declare class ParseExpressionPipe implements PipeMethods {
4
- transform(scope: PlatformParamsScope, param: JsonParameterStore): any;
5
- protected getKey(param: JsonParameterStore): string;
6
- }
@@ -1,12 +0,0 @@
1
- import { JsonParameterStore, PipeMethods } from "@tsed/schema";
2
- export type ValidatorServiceMethods = {
3
- validate(value: any, options: any): Promise<any>;
4
- };
5
- export declare class ValidationPipe implements PipeMethods {
6
- private validator;
7
- constructor(validators: ValidatorServiceMethods[]);
8
- coerceTypes(value: any, metadata: JsonParameterStore): any;
9
- skip(value: any, metadata: JsonParameterStore): boolean;
10
- transform(value: any, metadata: JsonParameterStore): Promise<any>;
11
- protected checkIsRequired(value: any, metadata: JsonParameterStore): boolean;
12
- }
@@ -1,5 +0,0 @@
1
- import { ParamOptions } from "../domain/ParamOptions.js";
2
- /**
3
- * @ignore
4
- */
5
- export declare function mapParamsOptions(args: any[]): Partial<ParamOptions<any>>;