@tsed/platform-params 6.95.9 → 6.95.10
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/package.json +11 -11
- package/lib/cjs/builder/PlatformParams.d.ts +0 -23
- package/lib/cjs/decorators/bodyParams.d.ts +0 -64
- package/lib/cjs/decorators/context.d.ts +0 -59
- package/lib/cjs/decorators/cookies.d.ts +0 -81
- package/lib/cjs/decorators/headerParams.d.ts +0 -33
- package/lib/cjs/decorators/locals.d.ts +0 -42
- package/lib/cjs/decorators/paramFn.d.ts +0 -11
- package/lib/cjs/decorators/pathParams.d.ts +0 -68
- package/lib/cjs/decorators/queryParams.d.ts +0 -73
- package/lib/cjs/decorators/session.d.ts +0 -36
- package/lib/cjs/decorators/useDeserialization.d.ts +0 -9
- package/lib/cjs/decorators/useParam.d.ts +0 -22
- package/lib/cjs/decorators/useParamExpression.d.ts +0 -10
- package/lib/cjs/decorators/useParamType.d.ts +0 -10
- package/lib/cjs/decorators/usePipe.d.ts +0 -13
- package/lib/cjs/decorators/useType.d.ts +0 -13
- package/lib/cjs/decorators/useValidation.d.ts +0 -9
- package/lib/cjs/domain/ParamMetadata.d.ts +0 -16
- package/lib/cjs/domain/ParamOptions.d.ts +0 -10
- package/lib/cjs/domain/ParamTypes.d.ts +0 -24
- package/lib/cjs/errors/ParamValidationError.d.ts +0 -8
- package/lib/cjs/errors/RequiredValidationError.d.ts +0 -6
- package/lib/cjs/errors/ValidationError.d.ts +0 -6
- package/lib/cjs/index.d.ts +0 -28
- package/lib/cjs/pipes/DeserializerPipe.d.ts +0 -5
- package/lib/cjs/pipes/ParseExpressionPipe.d.ts +0 -5
- package/lib/cjs/pipes/ValidationPipe.d.ts +0 -10
- package/lib/cjs/utils/mapParamsOptions.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-params",
|
|
3
|
-
"version": "6.95.
|
|
3
|
+
"version": "6.95.10",
|
|
4
4
|
"description": "Params module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"tslib": "2.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tsed/core": "6.95.
|
|
25
|
-
"@tsed/di": "6.95.
|
|
26
|
-
"@tsed/exceptions": "6.95.
|
|
27
|
-
"@tsed/json-mapper": "6.95.
|
|
28
|
-
"@tsed/schema": "6.95.
|
|
24
|
+
"@tsed/core": "6.95.10",
|
|
25
|
+
"@tsed/di": "6.95.10",
|
|
26
|
+
"@tsed/exceptions": "6.95.10",
|
|
27
|
+
"@tsed/json-mapper": "6.95.10",
|
|
28
|
+
"@tsed/schema": "6.95.10"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tsed/core": "^6.95.
|
|
32
|
-
"@tsed/di": "^6.95.
|
|
33
|
-
"@tsed/exceptions": "^6.95.
|
|
34
|
-
"@tsed/json-mapper": "^6.95.
|
|
35
|
-
"@tsed/schema": "^6.95.
|
|
31
|
+
"@tsed/core": "^6.95.10",
|
|
32
|
+
"@tsed/di": "^6.95.10",
|
|
33
|
+
"@tsed/exceptions": "^6.95.10",
|
|
34
|
+
"@tsed/json-mapper": "^6.95.10",
|
|
35
|
+
"@tsed/schema": "^6.95.10"
|
|
36
36
|
},
|
|
37
37
|
"repository": "https://github.com/tsedio/tsed",
|
|
38
38
|
"bugs": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { DIContext, InjectorService, TokenProvider } from "@tsed/di";
|
|
2
|
-
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
-
import { ParamMetadata, PipeMethods } from "../domain/ParamMetadata";
|
|
4
|
-
export declare type ArgScope<Context extends DIContext = DIContext> = {
|
|
5
|
-
$ctx: Context;
|
|
6
|
-
} & Record<string, any>;
|
|
7
|
-
export declare type HandlerWithScope<Context extends DIContext = DIContext> = (scope: ArgScope<Context>) => any;
|
|
8
|
-
export interface CompileHandlerOptions<Context extends DIContext = DIContext> extends Record<any, unknown> {
|
|
9
|
-
token: TokenProvider;
|
|
10
|
-
propertyKey: string | symbol;
|
|
11
|
-
getCustomArgs?: (scope: ArgScope<Context>) => Promise<any[]>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Platform Params abstraction layer.
|
|
15
|
-
* @platform
|
|
16
|
-
*/
|
|
17
|
-
export declare class PlatformParams {
|
|
18
|
-
protected injector: InjectorService;
|
|
19
|
-
getPipes(param: ParamMetadata): Promise<PipeMethods<any, any>[]>;
|
|
20
|
-
compile<Context extends DIContext = DIContext>(entity: JsonEntityStore): Promise<(scope: ArgScope<Context>) => Promise<any[]>>;
|
|
21
|
-
getArg(scope: ArgScope, pipes: PipeMethods[], param: ParamMetadata): Promise<any>;
|
|
22
|
-
compileHandler<Context extends DIContext = DIContext>(metadata: CompileHandlerOptions<Context>): Promise<HandlerWithScope<Context>>;
|
|
23
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { ParamOptions } from "../domain/ParamOptions";
|
|
3
|
-
/**
|
|
4
|
-
* BodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) object.
|
|
5
|
-
*
|
|
6
|
-
* #### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Controller('/')
|
|
10
|
-
* class MyCtrl {
|
|
11
|
-
* @Post('/')
|
|
12
|
-
* create(@BodyParams() body: any) {
|
|
13
|
-
* console.log('Entire body', body);
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* @Post('/')
|
|
17
|
-
* create(@BodyParams('id') id: string) {
|
|
18
|
-
* console.log('ID', id);
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* @Post('/')
|
|
22
|
-
* create(@BodyParams('user') user: User) { // with deserialization
|
|
23
|
-
* console.log('user', user);
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* @Post('/')
|
|
27
|
-
* create(@BodyParams('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 BodyParams(expression: string, useType: Type<any>): ParameterDecorator;
|
|
41
|
-
export declare function BodyParams(expression: string): ParameterDecorator;
|
|
42
|
-
export declare function BodyParams(useType: Type<any>): ParameterDecorator;
|
|
43
|
-
export declare function BodyParams(options: Partial<ParamOptions>): ParameterDecorator;
|
|
44
|
-
export declare function BodyParams(): ParameterDecorator;
|
|
45
|
-
/**
|
|
46
|
-
* RawBodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) as a Buffer.
|
|
47
|
-
*
|
|
48
|
-
* #### Example
|
|
49
|
-
*
|
|
50
|
-
* ```typescript
|
|
51
|
-
* @Controller('/')
|
|
52
|
-
* class MyCtrl {
|
|
53
|
-
* @Post('/')
|
|
54
|
-
* create(@RawBodyParams() body: Buffer) {
|
|
55
|
-
* console.log('Entire body', body.toString("utf8"));
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @decorator
|
|
61
|
-
* @operation
|
|
62
|
-
* @input
|
|
63
|
-
*/
|
|
64
|
-
export declare function RawBodyParams(): ParameterDecorator;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { BaseContext } from "@tsed/di";
|
|
2
|
-
declare global {
|
|
3
|
-
namespace TsED {
|
|
4
|
-
interface Context {
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Context decorator return the @@PlatformContext@@ created by Ts.ED when request is handled by the server.
|
|
10
|
-
*
|
|
11
|
-
* It contains some information as following:
|
|
12
|
-
*
|
|
13
|
-
* - The request id,
|
|
14
|
-
* - The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`,
|
|
15
|
-
* - The current @@EndpointMetadata@@ resolved by Ts.ED during the request,
|
|
16
|
-
* - The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
17
|
-
*
|
|
18
|
-
* ::: tip
|
|
19
|
-
* The @@PlatformContext@@ inherit from Map class. So you can store any information with.
|
|
20
|
-
* :::
|
|
21
|
-
*
|
|
22
|
-
* #### Example
|
|
23
|
-
*
|
|
24
|
-
* ```typescript
|
|
25
|
-
* @Middleware()
|
|
26
|
-
* class AuthTokenMiddleware {
|
|
27
|
-
* use(@Req() request: Req, @Context() context: PlatformContext) {
|
|
28
|
-
* if (!context.has("auth")){
|
|
29
|
-
* context.set('auth', new AuthToken(request))
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* try {
|
|
33
|
-
* context.get("auth").claims() // check token
|
|
34
|
-
* } catch(er){
|
|
35
|
-
* throw new Forbidden("Access forbidden - Bad token")
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* @Controller('/')
|
|
41
|
-
* @UseBefore(AuthTokenMiddleware) // protect all routes for this controller
|
|
42
|
-
* class MyCtrl {
|
|
43
|
-
* @Get('/')
|
|
44
|
-
* get(@Context('auth') auth: AuthToken) {
|
|
45
|
-
* console.log('auth', auth);
|
|
46
|
-
* console.log('auth.accessToken', auth.accessToken);
|
|
47
|
-
* console.log('auth.idToken', auth.idToken);
|
|
48
|
-
* }
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @param expression The path of the property to get.
|
|
53
|
-
* @decorator
|
|
54
|
-
* @operation
|
|
55
|
-
* @input
|
|
56
|
-
*/
|
|
57
|
-
export declare function Context(expression: string): ParameterDecorator;
|
|
58
|
-
export declare function Context(): ParameterDecorator;
|
|
59
|
-
export declare type Context = BaseContext;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { ParamOptions } from "../domain/ParamOptions";
|
|
3
|
-
/**
|
|
4
|
-
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
|
|
5
|
-
*
|
|
6
|
-
* #### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Controller('/')
|
|
10
|
-
* class MyCtrl {
|
|
11
|
-
* @Post('/')
|
|
12
|
-
* create(@Cookies() cookies: any) {
|
|
13
|
-
* console.log('Entire cookies', cookies);
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* @Post('/')
|
|
17
|
-
* create(@Cookies('id') id: string) {
|
|
18
|
-
* console.log('ID', id);
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* @Post('/')
|
|
22
|
-
* create(@Cookies('user') user: IUser) {
|
|
23
|
-
* console.log('user', 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
|
-
* @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 CookiesParams(expression: string | any, useType: any): ParameterDecorator;
|
|
36
|
-
export declare function CookiesParams(): ParameterDecorator;
|
|
37
|
-
export declare function CookiesParams(expression: string | any): ParameterDecorator;
|
|
38
|
-
export declare function CookiesParams(options: ParamOptions<any>): ParameterDecorator;
|
|
39
|
-
/**
|
|
40
|
-
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
|
|
41
|
-
*
|
|
42
|
-
* #### Example
|
|
43
|
-
*
|
|
44
|
-
* ```typescript
|
|
45
|
-
* @Controller('/')
|
|
46
|
-
* class MyCtrl {
|
|
47
|
-
* @Post('/')
|
|
48
|
-
* create(@Cookies() body: any) {
|
|
49
|
-
* console.log('Entire body', body);
|
|
50
|
-
* }
|
|
51
|
-
*
|
|
52
|
-
* @Post('/')
|
|
53
|
-
* create(@Cookies('id') id: string) {
|
|
54
|
-
* console.log('ID', id);
|
|
55
|
-
* }
|
|
56
|
-
*
|
|
57
|
-
* @Post('/')
|
|
58
|
-
* create(@Cookies('user') user: User) { // with deserialization
|
|
59
|
-
* console.log('user', user);
|
|
60
|
-
* }
|
|
61
|
-
*
|
|
62
|
-
* @Post('/')
|
|
63
|
-
* create(@Cookies('users', User) users: User[]) { // with deserialization
|
|
64
|
-
* console.log('users', users);
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
* ```
|
|
68
|
-
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
69
|
-
*
|
|
70
|
-
* @param expression The path of the property to get.
|
|
71
|
-
* @param useType The type of the class that to be used to deserialize the data.
|
|
72
|
-
* @decorator
|
|
73
|
-
* @aliasof CookiesParams
|
|
74
|
-
* @operation
|
|
75
|
-
* @input
|
|
76
|
-
*/
|
|
77
|
-
export declare function Cookies(expression: string, useType: Type<any>): ParameterDecorator;
|
|
78
|
-
export declare function Cookies(expression: string): ParameterDecorator;
|
|
79
|
-
export declare function Cookies(useType: Type<any>): ParameterDecorator;
|
|
80
|
-
export declare function Cookies(options: Partial<ParamOptions>): ParameterDecorator;
|
|
81
|
-
export declare function Cookies(): ParameterDecorator;
|
|
@@ -1,33 +0,0 @@
|
|
|
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;
|
|
@@ -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 { 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;
|
|
@@ -1,68 +0,0 @@
|
|
|
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;
|
|
@@ -1,73 +0,0 @@
|
|
|
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;
|
|
@@ -1,36 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,24 +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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
package/lib/cjs/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { InjectorService } from "@tsed/di";
|
|
2
|
-
import { ParamMetadata, PipeMethods } 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
|
-
}
|