@tsed/platform-params 6.110.0 → 6.111.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/cjs/decorators/bodyParams.js +3 -10
- package/lib/cjs/decorators/bodyParams.js.map +1 -1
- package/lib/cjs/decorators/context.js +0 -1
- package/lib/cjs/decorators/context.js.map +1 -1
- package/lib/cjs/decorators/cookies.js +0 -1
- package/lib/cjs/decorators/cookies.js.map +1 -1
- package/lib/cjs/decorators/headerParams.js +0 -1
- package/lib/cjs/decorators/headerParams.js.map +1 -1
- package/lib/cjs/decorators/locals.js +0 -1
- package/lib/cjs/decorators/locals.js.map +1 -1
- package/lib/cjs/decorators/pathParams.js +0 -1
- package/lib/cjs/decorators/pathParams.js.map +1 -1
- package/lib/cjs/decorators/queryParams.js +4 -5
- package/lib/cjs/decorators/queryParams.js.map +1 -1
- package/lib/cjs/decorators/session.js +0 -1
- package/lib/cjs/decorators/session.js.map +1 -1
- package/lib/cjs/decorators/useParam.js +0 -1
- package/lib/cjs/decorators/useParam.js.map +1 -1
- package/lib/cjs/decorators/useParamType.js +8 -2
- package/lib/cjs/decorators/useParamType.js.map +1 -1
- package/lib/cjs/domain/ParamTypes.js +11 -1
- package/lib/cjs/domain/ParamTypes.js.map +1 -1
- package/lib/esm/decorators/bodyParams.js +3 -10
- package/lib/esm/decorators/bodyParams.js.map +1 -1
- package/lib/esm/decorators/context.js +0 -1
- package/lib/esm/decorators/context.js.map +1 -1
- package/lib/esm/decorators/cookies.js +0 -1
- package/lib/esm/decorators/cookies.js.map +1 -1
- package/lib/esm/decorators/headerParams.js +0 -1
- package/lib/esm/decorators/headerParams.js.map +1 -1
- package/lib/esm/decorators/locals.js +0 -1
- package/lib/esm/decorators/locals.js.map +1 -1
- package/lib/esm/decorators/pathParams.js +0 -1
- package/lib/esm/decorators/pathParams.js.map +1 -1
- package/lib/esm/decorators/queryParams.js +4 -5
- package/lib/esm/decorators/queryParams.js.map +1 -1
- package/lib/esm/decorators/session.js +0 -1
- package/lib/esm/decorators/session.js.map +1 -1
- package/lib/esm/decorators/useParam.js +0 -1
- package/lib/esm/decorators/useParam.js.map +1 -1
- package/lib/esm/decorators/useParamType.js +9 -3
- package/lib/esm/decorators/useParamType.js.map +1 -1
- package/lib/esm/domain/ParamTypes.js +10 -0
- package/lib/esm/domain/ParamTypes.js.map +1 -1
- package/lib/types/decorators/bodyParams.d.ts +1 -0
- package/lib/types/domain/ParamTypes.d.ts +1 -0
- package/package.json +11 -11
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RawBodyParams = exports.BodyParams = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
4
|
const ParamTypes_1 = require("../domain/ParamTypes");
|
|
6
5
|
const useParam_1 = require("./useParam");
|
|
7
6
|
const mapParamsOptions_1 = require("../utils/mapParamsOptions");
|
|
8
|
-
const schema_1 = require("@tsed/schema");
|
|
9
7
|
function BodyParams(...args) {
|
|
10
8
|
const { expression, useType, useConverter = true, useValidation = true } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
11
9
|
return (0, useParam_1.UseParam)({
|
|
12
10
|
paramType: ParamTypes_1.ParamTypes.BODY,
|
|
13
|
-
dataPath: "$ctx.request.body",
|
|
14
11
|
expression,
|
|
15
12
|
useType,
|
|
16
13
|
useConverter,
|
|
@@ -36,18 +33,14 @@ exports.BodyParams = BodyParams;
|
|
|
36
33
|
* @decorator
|
|
37
34
|
* @operation
|
|
38
35
|
* @input
|
|
36
|
+
* @alias BodyParams Example: @BodyParams() payload: Buffer
|
|
39
37
|
*/
|
|
40
38
|
function RawBodyParams() {
|
|
41
|
-
return (0,
|
|
39
|
+
return (0, useParam_1.UseParam)({
|
|
42
40
|
paramType: ParamTypes_1.ParamTypes.RAW_BODY,
|
|
43
|
-
dataPath: "$ctx.request.rawBody",
|
|
44
|
-
useType: String,
|
|
45
41
|
useConverter: false,
|
|
46
42
|
useValidation: false
|
|
47
|
-
})
|
|
48
|
-
var _a;
|
|
49
|
-
(_a = entity.parent.operation) === null || _a === void 0 ? void 0 : _a.consumes(["*/*"]);
|
|
50
|
-
}));
|
|
43
|
+
});
|
|
51
44
|
}
|
|
52
45
|
exports.RawBodyParams = RawBodyParams;
|
|
53
46
|
//# sourceMappingURL=bodyParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bodyParams.js","sourceRoot":"","sources":["../../../src/decorators/bodyParams.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bodyParams.js","sourceRoot":"","sources":["../../../src/decorators/bodyParams.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAChD,yCAAoC;AACpC,gEAA2D;AA4C3D,SAAgB,UAAU,CAAC,GAAG,IAAW;IACvC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,IAAI;QAC1B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,gCAUC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,QAAQ;QAC9B,YAAY,EAAE,KAAK;QACnB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC;AAND,sCAMC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {UseParam} from \"./useParam\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\n\n/**\n * BodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@BodyParams() body: any) {\n * console.log('Entire body', body);\n * }\n *\n * @Post('/')\n * create(@BodyParams('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/')\n * create(@BodyParams('user') user: User) { // with deserialization\n * console.log('user', user);\n * }\n *\n * @Post('/')\n * create(@BodyParams('users', User) users: User[]) { // with deserialization\n * console.log('users', users);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function BodyParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function BodyParams(expression: string): ParameterDecorator;\nexport function BodyParams(useType: Type<any>): ParameterDecorator;\nexport function BodyParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function BodyParams(): ParameterDecorator;\nexport function BodyParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = true, useValidation = true} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.BODY,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * RawBodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) as a Buffer.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@RawBodyParams() body: Buffer) {\n * console.log('Entire body', body.toString(\"utf8\"));\n * }\n * }\n * ```\n *\n * @decorator\n * @operation\n * @input\n * @alias BodyParams Example: @BodyParams() payload: Buffer\n */\nexport function RawBodyParams(): ParameterDecorator {\n return UseParam({\n paramType: ParamTypes.RAW_BODY,\n useConverter: false,\n useValidation: false\n });\n}\n"]}
|
|
@@ -8,7 +8,6 @@ function Context(...args) {
|
|
|
8
8
|
const { expression, useType, useConverter = false, useValidation = false } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
9
9
|
return (0, useParam_1.UseParam)({
|
|
10
10
|
paramType: ParamTypes_1.ParamTypes.$CTX,
|
|
11
|
-
dataPath: "$ctx",
|
|
12
11
|
expression,
|
|
13
12
|
useType,
|
|
14
13
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/decorators/context.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAqDpC,SAAgB,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,IAAI;QAC1B,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/decorators/context.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAqDpC,SAAgB,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,IAAI;QAC1B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,0BAUC","sourcesContent":["import {BaseContext} from \"@tsed/di\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Context decorator return the @@PlatformContext@@ created by Ts.ED when request is handled by the server.\n *\n * It contains some information as following:\n *\n * - The request id,\n * - The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`,\n * - The current @@EndpointMetadata@@ resolved by Ts.ED during the request,\n * - The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n *\n * ::: tip\n * The @@PlatformContext@@ inherit from Map class. So you can store any information with.\n * :::\n *\n * #### Example\n *\n * ```typescript\n * @Middleware()\n * class AuthTokenMiddleware {\n * use(@Req() request: Req, @Context() context: PlatformContext) {\n * if (!context.has(\"auth\")){\n * context.set('auth', new AuthToken(request))\n * }\n *\n * try {\n * context.get(\"auth\").claims() // check token\n * } catch(er){\n * throw new Forbidden(\"Access forbidden - Bad token\")\n * }\n * }\n * }\n *\n * @Controller('/')\n * @UseBefore(AuthTokenMiddleware) // protect all routes for this controller\n * class MyCtrl {\n * @Get('/')\n * get(@Context('auth') auth: AuthToken) {\n * console.log('auth', auth);\n * console.log('auth.accessToken', auth.accessToken);\n * console.log('auth.idToken', auth.idToken);\n * }\n * }\n * ```\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function Context(expression: string): ParameterDecorator;\nexport function Context(): ParameterDecorator;\nexport function Context(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.$CTX,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\nexport type Context = BaseContext;\n"]}
|
|
@@ -8,7 +8,6 @@ function CookiesParams(...args) {
|
|
|
8
8
|
const { expression, useType, useConverter = false, useValidation = false } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
9
9
|
return (0, useParam_1.UseParam)({
|
|
10
10
|
paramType: ParamTypes_1.ParamTypes.COOKIES,
|
|
11
|
-
dataPath: "$ctx.request.cookies",
|
|
12
11
|
expression,
|
|
13
12
|
useType,
|
|
14
13
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../../src/decorators/cookies.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAsCpC,SAAgB,aAAa,CAAC,GAAG,IAAW;IAC1C,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,OAAO;QAC7B,
|
|
1
|
+
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../../src/decorators/cookies.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAsCpC,SAAgB,aAAa,CAAC,GAAG,IAAW;IAC1C,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,OAAO;QAC7B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,sCAUC;AA6CD,SAAgB,OAAO,CAAC,GAAG,IAAW;IACpC,aAAa;IACb,OAAO,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC;AAHD,0BAGC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@Cookies() cookies: any) {\n * console.log('Entire cookies', cookies);\n * }\n *\n * @Post('/')\n * create(@Cookies('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/')\n * create(@Cookies('user') user: IUser) {\n * console.log('user', user);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function CookiesParams(expression: string | any, useType: any): ParameterDecorator;\nexport function CookiesParams(): ParameterDecorator;\nexport function CookiesParams(expression: string | any): ParameterDecorator;\nexport function CookiesParams(options: ParamOptions<any>): ParameterDecorator;\nexport function CookiesParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.COOKIES,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@Cookies() body: any) {\n * console.log('Entire body', body);\n * }\n *\n * @Post('/')\n * create(@Cookies('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/')\n * create(@Cookies('user') user: User) { // with deserialization\n * console.log('user', user);\n * }\n *\n * @Post('/')\n * create(@Cookies('users', User) users: User[]) { // with deserialization\n * console.log('users', users);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @aliasof CookiesParams\n * @operation\n * @input\n */\nexport function Cookies(expression: string, useType: Type<any>): ParameterDecorator;\nexport function Cookies(expression: string): ParameterDecorator;\nexport function Cookies(useType: Type<any>): ParameterDecorator;\nexport function Cookies(options: Partial<ParamOptions>): ParameterDecorator;\nexport function Cookies(): ParameterDecorator;\nexport function Cookies(...args: any[]): ParameterDecorator {\n // @ts-ignore\n return CookiesParams(...args);\n}\n"]}
|
|
@@ -8,7 +8,6 @@ function HeaderParams(...args) {
|
|
|
8
8
|
const { expression, useType, useConverter = false, useValidation = false } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
9
9
|
return (0, useParam_1.UseParam)({
|
|
10
10
|
paramType: ParamTypes_1.ParamTypes.HEADER,
|
|
11
|
-
dataPath: "$ctx.request.headers",
|
|
12
11
|
expression,
|
|
13
12
|
useType,
|
|
14
13
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headerParams.js","sourceRoot":"","sources":["../../../src/decorators/headerParams.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,yCAAoC;AACpC,gEAA2D;AAkC3D,SAAgB,YAAY,CAAC,GAAG,IAAW;IACzC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,MAAM;QAC5B,
|
|
1
|
+
{"version":3,"file":"headerParams.js","sourceRoot":"","sources":["../../../src/decorators/headerParams.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,yCAAoC;AACpC,gEAA2D;AAkC3D,SAAgB,YAAY,CAAC,GAAG,IAAW;IACzC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,MAAM;QAC5B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,oCAUC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {UseParam} from \"./useParam\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\n\n/**\n * HeaderParams return the value from [`request.get()`](http://expressjs.com/en/4x/api.html#req.get) method.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@HeaderParams() body: any) {\n * console.log('Entire body', body);\n * }\n *\n * @Get('/')\n * get(@HeaderParams('x-token') token: string) {\n * console.log('token', id);\n * }\n * }\n * ```\n *\n * @param expression The path of the property to get.\n * @param useType\n * @decorator\n * @operation\n * @input\n */\nexport function HeaderParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function HeaderParams(expression: string): ParameterDecorator;\nexport function HeaderParams(useType: Type<any>): ParameterDecorator;\nexport function HeaderParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function HeaderParams(): ParameterDecorator;\nexport function HeaderParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.HEADER,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n"]}
|
|
@@ -8,7 +8,6 @@ function Locals(...args) {
|
|
|
8
8
|
const { expression, useType, useConverter = false, useValidation = false } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
9
9
|
return (0, useParam_1.UseParam)({
|
|
10
10
|
paramType: ParamTypes_1.ParamTypes.LOCALS,
|
|
11
|
-
dataPath: "$ctx.response.locals",
|
|
12
11
|
expression,
|
|
13
12
|
useType,
|
|
14
13
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locals.js","sourceRoot":"","sources":["../../../src/decorators/locals.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AA4CpC,SAAgB,MAAM,CAAC,GAAG,IAAW;IACnC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,MAAM;QAC5B,
|
|
1
|
+
{"version":3,"file":"locals.js","sourceRoot":"","sources":["../../../src/decorators/locals.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AA4CpC,SAAgB,MAAM,CAAC,GAAG,IAAW;IACnC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,MAAM;QAC5B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,wBAUC","sourcesContent":["import {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Locals return the value from [response.locals](http://expressjs.com/en/4x/api.html#res.locals) object.\n *\n * ::: tip\n * Locals are generally used by express and third-party like templating engine to render a page/template.\n * See [Templating](http://tsed.io/tutorials/templating.html) section for more details.\n * :::\n *\n * #### Example\n *\n * ```typescript\n * * @Middleware()\n * class LocalsMiddleware {\n * use(@Locals() locals: any) {\n * // set some on locals\n * locals.user = \"user\"\n * }\n * }\n *\n * @Controller('/')\n * @UseBefore(LocalsMiddleware)\n * class MyCtrl {\n * @Get('/')\n * @View('home.ejs') // will use locals and returned data to render the page\n * get(@Locals('user') user: any) {\n * console.log('user', user);\n *\n * return {\n * description: 'Hello world'\n * }\n * }\n * }\n * ```\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport function Locals(expression: string): ParameterDecorator;\nexport function Locals(): ParameterDecorator;\nexport function Locals(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.LOCALS,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n"]}
|
|
@@ -8,7 +8,6 @@ function PathParams(...args) {
|
|
|
8
8
|
const { expression, useType, useConverter = true, useValidation = true } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
9
9
|
return (0, useParam_1.UseParam)({
|
|
10
10
|
paramType: ParamTypes_1.ParamTypes.PATH,
|
|
11
|
-
dataPath: "$ctx.request.params",
|
|
12
11
|
expression,
|
|
13
12
|
useType,
|
|
14
13
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathParams.js","sourceRoot":"","sources":["../../../src/decorators/pathParams.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAuCpC,SAAgB,UAAU,CAAC,GAAG,IAAW;IACvC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,IAAI;QAC1B,
|
|
1
|
+
{"version":3,"file":"pathParams.js","sourceRoot":"","sources":["../../../src/decorators/pathParams.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAuCpC,SAAgB,UAAU,CAAC,GAAG,IAAW;IACvC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,IAAI;QAC1B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,gCAUC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,aAAa,CAAC,UAAkB;IAC9C,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,IAAI;QAC1B,QAAQ,EAAE,qBAAqB;QAC/B,UAAU;KACX,CAAC,CAAC;AACL,CAAC;AAND,sCAMC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * PathParams return the value from [request.params](http://expressjs.com/en/4x/api.html#req.params) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@PathParams() params: any) {\n * console.log('Entire params', params);\n * }\n *\n * @Get('/')\n * get(@PathParams('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Get('/')\n * get(@PathParams({expression: 'id', useType: () => new MyCustomModel() }) id: string) {\n * console.log('ID', id);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function PathParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function PathParams(expression: string): ParameterDecorator;\nexport function PathParams(useType: Type<any>): ParameterDecorator;\nexport function PathParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function PathParams(): ParameterDecorator;\nexport function PathParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = true, useValidation = true} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.PATH,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * RawPathParams return the raw value from [request.params](http://expressjs.com/en/4x/api.html#req.params) object.\n *\n * Any validation and transformation are performed on the value. Use [pipes](/docs/pipes.html) to validate and/or transform the value.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@RawPathParams() params: string) {\n * console.log('Entire params', params);\n * }\n *\n * @Get('/')\n * get(@RawPathParams('id') id: string) {\n * console.log('ID', id);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function RawPathParams(expression: string) {\n return UseParam({\n paramType: ParamTypes.PATH,\n dataPath: \"$ctx.request.params\",\n expression\n });\n}\n"]}
|
|
@@ -8,7 +8,6 @@ function QueryParams(...args) {
|
|
|
8
8
|
const { expression, useType, useConverter = true, useValidation = true } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
9
9
|
return (0, useParam_1.UseParam)({
|
|
10
10
|
paramType: ParamTypes_1.ParamTypes.QUERY,
|
|
11
|
-
dataPath: "$ctx.request.query",
|
|
12
11
|
expression,
|
|
13
12
|
useType,
|
|
14
13
|
useConverter,
|
|
@@ -45,10 +44,10 @@ exports.QueryParams = QueryParams;
|
|
|
45
44
|
* @input
|
|
46
45
|
*/
|
|
47
46
|
function RawQueryParams(expression) {
|
|
48
|
-
return (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
return QueryParams({
|
|
48
|
+
expression,
|
|
49
|
+
useConverters: false,
|
|
50
|
+
useValidation: false
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
exports.RawQueryParams = RawQueryParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryParams.js","sourceRoot":"","sources":["../../../src/decorators/queryParams.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AA4CpC,SAAgB,WAAW,CAAC,GAAG,IAAW;IACxC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,KAAK;QAC3B,
|
|
1
|
+
{"version":3,"file":"queryParams.js","sourceRoot":"","sources":["../../../src/decorators/queryParams.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AA4CpC,SAAgB,WAAW,CAAC,GAAG,IAAW;IACxC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,KAAK;QAC3B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,kCAUC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,cAAc,CAAC,UAAkB;IAC/C,OAAO,WAAW,CAAC;QACjB,UAAU;QACV,aAAa,EAAE,KAAK;QACpB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC;AAND,wCAMC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * QueryParams return the value from [request.query](http://expressjs.com/en/4x/api.html#req.query) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@QueryParams() query: any) {\n * console.log('Entire query', query);\n * }\n *\n * @Get('/')\n * get(@QueryParams('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Get('/')\n * get(@QueryParams('user') user: User) { // with deserialization\n * console.log('user', user);\n * }\n *\n * @Get('/')\n * get(@QueryParams('users', User) users: User[]) { // with deserialization\n * console.log('users', users);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function QueryParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function QueryParams(expression: string): ParameterDecorator;\nexport function QueryParams(useType: Type<any>): ParameterDecorator;\nexport function QueryParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function QueryParams(): ParameterDecorator;\nexport function QueryParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = true, useValidation = true} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.QUERY,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * RawQueryParams return the value from [request.query](http://expressjs.com/en/4x/api.html#req.query) object.\n *\n * Any validation and transformation are performed on the value. Use [pipes](/docs/pipes.html) to validate and/or transform the value.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@RawPathParams() params: any) {\n * console.log('Entire params', params);\n * }\n *\n * @Get('/')\n * get(@RawPathParams('id') id: string) {\n * console.log('ID', id);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function RawQueryParams(expression: string) {\n return QueryParams({\n expression,\n useConverters: false,\n useValidation: false\n });\n}\n"]}
|
|
@@ -8,7 +8,6 @@ function Session(...args) {
|
|
|
8
8
|
const { expression, useType, useConverter = false, useValidation = false } = (0, mapParamsOptions_1.mapParamsOptions)(args);
|
|
9
9
|
return (0, useParam_1.UseParam)({
|
|
10
10
|
paramType: ParamTypes_1.ParamTypes.SESSION,
|
|
11
|
-
dataPath: "$ctx.request.session",
|
|
12
11
|
expression,
|
|
13
12
|
useType,
|
|
14
13
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/decorators/session.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAqCpC,SAAgB,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,OAAO;QAC7B,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/decorators/session.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,gEAA2D;AAC3D,yCAAoC;AAqCpC,SAAgB,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,IAAA,mBAAQ,EAAC;QACd,SAAS,EAAE,uBAAU,CAAC,OAAO;QAC7B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAVD,0BAUC","sourcesContent":["import {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Session return the value from [request.session](http://expressjs.com/en/4x/api.html#req.session) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@Session() session: Express.Session) {\n * console.log('Entire session', session);\n * }\n *\n * @Post('/')\n * create(@Session('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/') // Example to deserialize use from session\n * create(@Session({expression: 'user', useConverter: true}) user: User) {\n * console.log('user', user);\n * console.log('instanceOf user', user instanceof User);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function Session(expression: string): ParameterDecorator;\nexport function Session(options: Partial<ParamOptions>): ParameterDecorator;\nexport function Session(): ParameterDecorator;\nexport function Session(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.SESSION,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":";;;AAAA,qCAA6D;AAC7D,yCAAiC;AAEjC,qDAAgD;AAChD,uCAAkC;AAClC,6DAAwD;AACxD,iDAA4C;AAC5C,uCAAkC;AAClC,mDAA8C;AAE9C;;;GAGG;AACH,SAAS,QAAQ,CAAC,OAA8B;IAC9C,MAAM,EAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;IAExF,OAAO;QACL,OAAO;YACL,CAAC,CAAC,IAAA,iBAAO,EAAC,OAAO,CAAC;YAClB,CAAC,CAAC,IAAA,iBAAO,EAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;gBAC7B,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,SAAS,KAAK,uBAAU,CAAC,KAAK,EAAE;oBACnF,IAAA,YAAG,GAAE,CAAC,GAAG,UAAU,CAAC,CAAC;iBACtB;YACH,CAAC,CAAC;QACN,aAAa,IAAI,IAAA,6BAAa,GAAE;QAChC,YAAY,IAAI,IAAA,uCAAkB,EAAC,KAAK,CAAC;KAC1C,CAAC;AACJ,CAAC;AAuBD,SAAgB,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClD,SAAS,EAAE,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KAC3D,CAAC;IAEF,OAAO,IAAA,oBAAa,EAAC,IAAA,2BAAY,EAAC,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AAC1F,CAAC;AAPD,4BAOC","sourcesContent":["import {isBuffer, isString, useDecorators} from \"@tsed/core\";\nimport {Any} from \"@tsed/schema\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {ParamFn} from \"./paramFn\";\nimport {UseDeserialization} from \"./useDeserialization\";\nimport {UseParamType} from \"./useParamType\";\nimport {UseType} from \"./useType\";\nimport {UseValidation} from \"./useValidation\";\n\n/**\n * @ignore\n * @param options\n */\nfunction mapPipes(options: Partial<ParamOptions>) {\n const {paramType, useType, expression, useValidation, useConverter, ...props} = options;\n\n return [\n useType\n ? UseType(useType)\n : ParamFn((entity, parameters) => {\n if (entity.isCollection && entity.type === Object && paramType !== ParamTypes.FILES) {\n Any()(...parameters);\n }\n }),\n useValidation && UseValidation(),\n useConverter && UseDeserialization(props)\n ];\n}\n\n/**\n * Register a new param. It use the paramType to extract value and give it to the next pipe.\n *\n * Given options allow to enable or disable following pipes:\n *\n * - useType: Add extra type for the json mapper,\n * - expression: Get property from the returned value by the previous pipe.\n * - useValidation: Apply validation from the returned value by the previous pipe.\n * - useConverter: Apply json mapper from the returned value by the previous pipe.\n *\n * @param options\n * @decorator\n * @operation\n * @input\n * @pipe\n */\nexport function UseParam(options: Partial<ParamOptions>): ParameterDecorator;\n/**\n * @deprecated Since v6\n */\nexport function UseParam(paramType: string, options?: Partial<ParamOptions>): ParameterDecorator;\nexport function UseParam(...args: any[]): ParameterDecorator {\n const options = {\n ...((isString(args[0]) ? args[1] : args[0]) || {}),\n paramType: isString(args[0]) ? args[0] : args[0].paramType\n };\n\n return useDecorators(UseParamType(options), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
|
|
@@ -5,6 +5,7 @@ const core_1 = require("@tsed/core");
|
|
|
5
5
|
const schema_1 = require("@tsed/schema");
|
|
6
6
|
const paramFn_1 = require("./paramFn");
|
|
7
7
|
const useParamExpression_1 = require("./useParamExpression");
|
|
8
|
+
const ParamTypes_1 = require("../domain/ParamTypes");
|
|
8
9
|
/**
|
|
9
10
|
* Get the object from request (like body, params, query, etc...).
|
|
10
11
|
*
|
|
@@ -15,12 +16,17 @@ const useParamExpression_1 = require("./useParamExpression");
|
|
|
15
16
|
*/
|
|
16
17
|
function UseParamType(options) {
|
|
17
18
|
return (0, core_1.useDecorators)((0, paramFn_1.ParamFn)((param) => {
|
|
19
|
+
var _a;
|
|
18
20
|
if ((0, schema_1.isParameterType)(options.paramType)) {
|
|
19
21
|
param.parameter.in(options.paramType);
|
|
20
22
|
}
|
|
21
23
|
param.paramType = options.paramType;
|
|
22
|
-
param.
|
|
23
|
-
|
|
24
|
+
if ((0, core_1.isBuffer)(param.type) || (0, core_1.isBuffer)(options.useType) || options.paramType === ParamTypes_1.ParamTypes.RAW_BODY) {
|
|
25
|
+
param.paramType = ParamTypes_1.ParamTypes.RAW_BODY;
|
|
26
|
+
(_a = param.parent.operation) === null || _a === void 0 ? void 0 : _a.consumes(["*/*"]);
|
|
27
|
+
}
|
|
28
|
+
param.dataPath = options.dataPath || ParamTypes_1.PARAM_TYPES_DATA_PATH[param.paramType] || "$ctx";
|
|
29
|
+
}), options.expression && (0, useParamExpression_1.UseParamExpression)(options.expression), options.expression && (0, schema_1.Name)(options.expression));
|
|
24
30
|
}
|
|
25
31
|
exports.UseParamType = UseParamType;
|
|
26
32
|
//# sourceMappingURL=useParamType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParamType.js","sourceRoot":"","sources":["../../../src/decorators/useParamType.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"useParamType.js","sourceRoot":"","sources":["../../../src/decorators/useParamType.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAmD;AACnD,uCAAkC;AAElC,6DAAwD;AACxD,qDAAuE;AAEvE;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,OAAqB;IAChD,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAO,EAAC,CAAC,KAAK,EAAE,EAAE;;QAChB,IAAI,IAAA,wBAAe,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACtC,KAAK,CAAC,SAAU,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SACxC;QAED,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAEpC,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,SAAS,KAAK,uBAAU,CAAC,QAAQ,EAAE;YAClG,KAAK,CAAC,SAAS,GAAG,uBAAU,CAAC,QAAQ,CAAC;YACtC,MAAA,KAAK,CAAC,MAAM,CAAC,SAAS,0CAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;SAC3C;QAED,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,kCAAqB,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC;IACxF,CAAC,CAAC,EACF,OAAO,CAAC,UAAU,IAAI,IAAA,uCAAkB,EAAC,OAAO,CAAC,UAAU,CAAC,EAC5D,OAAO,CAAC,UAAU,IAAI,IAAA,aAAI,EAAC,OAAO,CAAC,UAAU,CAAC,CAC/C,CAAC;AACJ,CAAC;AAnBD,oCAmBC","sourcesContent":["import {isBuffer, useDecorators} from \"@tsed/core\";\nimport {isParameterType, Name} from \"@tsed/schema\";\nimport {ParamFn} from \"./paramFn\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {UseParamExpression} from \"./useParamExpression\";\nimport {PARAM_TYPES_DATA_PATH, ParamTypes} from \"../domain/ParamTypes\";\n\n/**\n * Get the object from request (like body, params, query, etc...).\n *\n * @decorator\n * @operation\n * @input\n * @pipe\n */\nexport function UseParamType(options: ParamOptions) {\n return useDecorators(\n ParamFn((param) => {\n if (isParameterType(options.paramType)) {\n param.parameter!.in(options.paramType);\n }\n\n param.paramType = options.paramType;\n\n if (isBuffer(param.type) || isBuffer(options.useType) || options.paramType === ParamTypes.RAW_BODY) {\n param.paramType = ParamTypes.RAW_BODY;\n param.parent.operation?.consumes([\"*/*\"]);\n }\n\n param.dataPath = options.dataPath || PARAM_TYPES_DATA_PATH[param.paramType] || \"$ctx\";\n }),\n options.expression && UseParamExpression(options.expression),\n options.expression && Name(options.expression)\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParamTypes = void 0;
|
|
3
|
+
exports.PARAM_TYPES_DATA_PATH = exports.ParamTypes = void 0;
|
|
4
4
|
var ParamTypes;
|
|
5
5
|
(function (ParamTypes) {
|
|
6
6
|
ParamTypes["$CTX"] = "$CTX";
|
|
@@ -27,4 +27,14 @@ var ParamTypes;
|
|
|
27
27
|
ParamTypes["RES"] = "RES";
|
|
28
28
|
ParamTypes["REQ"] = "REQ";
|
|
29
29
|
})(ParamTypes = exports.ParamTypes || (exports.ParamTypes = {}));
|
|
30
|
+
exports.PARAM_TYPES_DATA_PATH = {
|
|
31
|
+
[ParamTypes.HEADER]: "$ctx.request.headers",
|
|
32
|
+
[ParamTypes.RAW_BODY]: "$ctx.request.rawBody",
|
|
33
|
+
[ParamTypes.BODY]: "$ctx.request.body",
|
|
34
|
+
[ParamTypes.QUERY]: "$ctx.request.query",
|
|
35
|
+
[ParamTypes.PATH]: "$ctx.request.params",
|
|
36
|
+
[ParamTypes.COOKIES]: "$ctx.request.cookies",
|
|
37
|
+
[ParamTypes.SESSION]: "$ctx.request.session",
|
|
38
|
+
[ParamTypes.LOCALS]: "$ctx.response.locals"
|
|
39
|
+
};
|
|
30
40
|
//# sourceMappingURL=ParamTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParamTypes.js","sourceRoot":"","sources":["../../../src/domain/ParamTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAyBX;AAzBD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IAEf,WAAW;IACX,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,iCAAmB,CAAA;IACnB,mDAAqC,CAAA;IACrC,2CAA6B,CAAA;IAC7B,mCAAqB,CAAA;IACrB,qDAAuC,CAAA;IACvC,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,yBAAW,CAAA;IACX,yBAAW,CAAA;AACb,CAAC,EAzBW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAyBrB","sourcesContent":["export enum ParamTypes {\n $CTX = \"$CTX\",\n BODY = \"BODY\",\n PATH = \"PATH\",\n QUERY = \"QUERY\",\n HEADER = \"HEADER\",\n RAW_BODY = \"RAW_BODY\",\n COOKIES = \"COOKIES\",\n LOCALS = \"LOCALS\",\n SESSION = \"SESSION\",\n FILES = \"FILES\",\n\n /// NOT STD\n NEXT_FN = \"NEXT_FN\",\n ERR = \"ERR\",\n REQUEST = \"REQUEST\",\n PLATFORM_REQUEST = \"PLATFORM_REQUEST\",\n NODE_REQUEST = \"NODE_REQUEST\",\n RESPONSE = \"RESPONSE\",\n PLATFORM_RESPONSE = \"PLATFORM_RESPONSE\",\n NODE_RESPONSE = \"NODE_RESPONSE\",\n RESPONSE_DATA = \"RESPONSE_DATA\",\n ENDPOINT_INFO = \"ENDPOINT_INFO\",\n RES = \"RES\",\n REQ = \"REQ\"\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ParamTypes.js","sourceRoot":"","sources":["../../../src/domain/ParamTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAyBX;AAzBD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IAEf,WAAW;IACX,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,iCAAmB,CAAA;IACnB,mDAAqC,CAAA;IACrC,2CAA6B,CAAA;IAC7B,mCAAqB,CAAA;IACrB,qDAAuC,CAAA;IACvC,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,yBAAW,CAAA;IACX,yBAAW,CAAA;AACb,CAAC,EAzBW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAyBrB;AAEY,QAAA,qBAAqB,GAA2B;IAC3D,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;IAC3C,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,sBAAsB;IAC7C,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,mBAAmB;IACtC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,oBAAoB;IACxC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,qBAAqB;IACxC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;CAC5C,CAAC","sourcesContent":["export enum ParamTypes {\n $CTX = \"$CTX\",\n BODY = \"BODY\",\n PATH = \"PATH\",\n QUERY = \"QUERY\",\n HEADER = \"HEADER\",\n RAW_BODY = \"RAW_BODY\",\n COOKIES = \"COOKIES\",\n LOCALS = \"LOCALS\",\n SESSION = \"SESSION\",\n FILES = \"FILES\",\n\n /// NOT STD\n NEXT_FN = \"NEXT_FN\",\n ERR = \"ERR\",\n REQUEST = \"REQUEST\",\n PLATFORM_REQUEST = \"PLATFORM_REQUEST\",\n NODE_REQUEST = \"NODE_REQUEST\",\n RESPONSE = \"RESPONSE\",\n PLATFORM_RESPONSE = \"PLATFORM_RESPONSE\",\n NODE_RESPONSE = \"NODE_RESPONSE\",\n RESPONSE_DATA = \"RESPONSE_DATA\",\n ENDPOINT_INFO = \"ENDPOINT_INFO\",\n RES = \"RES\",\n REQ = \"REQ\"\n}\n\nexport const PARAM_TYPES_DATA_PATH: Record<string, string> = {\n [ParamTypes.HEADER]: \"$ctx.request.headers\",\n [ParamTypes.RAW_BODY]: \"$ctx.request.rawBody\",\n [ParamTypes.BODY]: \"$ctx.request.body\",\n [ParamTypes.QUERY]: \"$ctx.request.query\",\n [ParamTypes.PATH]: \"$ctx.request.params\",\n [ParamTypes.COOKIES]: \"$ctx.request.cookies\",\n [ParamTypes.SESSION]: \"$ctx.request.session\",\n [ParamTypes.LOCALS]: \"$ctx.response.locals\"\n};\n"]}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { useDecorators } from "@tsed/core";
|
|
2
1
|
import { ParamTypes } from "../domain/ParamTypes.js";
|
|
3
2
|
import { UseParam } from "./useParam.js";
|
|
4
3
|
import { mapParamsOptions } from "../utils/mapParamsOptions.js";
|
|
5
|
-
import { JsonEntityFn } from "@tsed/schema";
|
|
6
4
|
export function BodyParams(...args) {
|
|
7
5
|
const { expression, useType, useConverter = true, useValidation = true } = mapParamsOptions(args);
|
|
8
6
|
return UseParam({
|
|
9
7
|
paramType: ParamTypes.BODY,
|
|
10
|
-
dataPath: "$ctx.request.body",
|
|
11
8
|
expression,
|
|
12
9
|
useType,
|
|
13
10
|
useConverter,
|
|
@@ -32,17 +29,13 @@ export function BodyParams(...args) {
|
|
|
32
29
|
* @decorator
|
|
33
30
|
* @operation
|
|
34
31
|
* @input
|
|
32
|
+
* @alias BodyParams Example: @BodyParams() payload: Buffer
|
|
35
33
|
*/
|
|
36
34
|
export function RawBodyParams() {
|
|
37
|
-
return
|
|
35
|
+
return UseParam({
|
|
38
36
|
paramType: ParamTypes.RAW_BODY,
|
|
39
|
-
dataPath: "$ctx.request.rawBody",
|
|
40
|
-
useType: String,
|
|
41
37
|
useConverter: false,
|
|
42
38
|
useValidation: false
|
|
43
|
-
})
|
|
44
|
-
var _a;
|
|
45
|
-
(_a = entity.parent.operation) === null || _a === void 0 ? void 0 : _a.consumes(["*/*"]);
|
|
46
|
-
}));
|
|
39
|
+
});
|
|
47
40
|
}
|
|
48
41
|
//# sourceMappingURL=bodyParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bodyParams.js","sourceRoot":"","sources":["../../../src/decorators/bodyParams.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bodyParams.js","sourceRoot":"","sources":["../../../src/decorators/bodyParams.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AA4C3D,MAAM,UAAU,UAAU,CAAC,GAAG,IAAW;IACvC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,IAAI;QAC1B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,QAAQ;QAC9B,YAAY,EAAE,KAAK;QACnB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {UseParam} from \"./useParam\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\n\n/**\n * BodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@BodyParams() body: any) {\n * console.log('Entire body', body);\n * }\n *\n * @Post('/')\n * create(@BodyParams('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/')\n * create(@BodyParams('user') user: User) { // with deserialization\n * console.log('user', user);\n * }\n *\n * @Post('/')\n * create(@BodyParams('users', User) users: User[]) { // with deserialization\n * console.log('users', users);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function BodyParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function BodyParams(expression: string): ParameterDecorator;\nexport function BodyParams(useType: Type<any>): ParameterDecorator;\nexport function BodyParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function BodyParams(): ParameterDecorator;\nexport function BodyParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = true, useValidation = true} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.BODY,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * RawBodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) as a Buffer.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@RawBodyParams() body: Buffer) {\n * console.log('Entire body', body.toString(\"utf8\"));\n * }\n * }\n * ```\n *\n * @decorator\n * @operation\n * @input\n * @alias BodyParams Example: @BodyParams() payload: Buffer\n */\nexport function RawBodyParams(): ParameterDecorator {\n return UseParam({\n paramType: ParamTypes.RAW_BODY,\n useConverter: false,\n useValidation: false\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/decorators/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAqDpC,MAAM,UAAU,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,IAAI;QAC1B,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/decorators/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAqDpC,MAAM,UAAU,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,IAAI;QAC1B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {BaseContext} from \"@tsed/di\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Context decorator return the @@PlatformContext@@ created by Ts.ED when request is handled by the server.\n *\n * It contains some information as following:\n *\n * - The request id,\n * - The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`,\n * - The current @@EndpointMetadata@@ resolved by Ts.ED during the request,\n * - The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n *\n * ::: tip\n * The @@PlatformContext@@ inherit from Map class. So you can store any information with.\n * :::\n *\n * #### Example\n *\n * ```typescript\n * @Middleware()\n * class AuthTokenMiddleware {\n * use(@Req() request: Req, @Context() context: PlatformContext) {\n * if (!context.has(\"auth\")){\n * context.set('auth', new AuthToken(request))\n * }\n *\n * try {\n * context.get(\"auth\").claims() // check token\n * } catch(er){\n * throw new Forbidden(\"Access forbidden - Bad token\")\n * }\n * }\n * }\n *\n * @Controller('/')\n * @UseBefore(AuthTokenMiddleware) // protect all routes for this controller\n * class MyCtrl {\n * @Get('/')\n * get(@Context('auth') auth: AuthToken) {\n * console.log('auth', auth);\n * console.log('auth.accessToken', auth.accessToken);\n * console.log('auth.idToken', auth.idToken);\n * }\n * }\n * ```\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function Context(expression: string): ParameterDecorator;\nexport function Context(): ParameterDecorator;\nexport function Context(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.$CTX,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\nexport type Context = BaseContext;\n"]}
|
|
@@ -5,7 +5,6 @@ export function CookiesParams(...args) {
|
|
|
5
5
|
const { expression, useType, useConverter = false, useValidation = false } = mapParamsOptions(args);
|
|
6
6
|
return UseParam({
|
|
7
7
|
paramType: ParamTypes.COOKIES,
|
|
8
|
-
dataPath: "$ctx.request.cookies",
|
|
9
8
|
expression,
|
|
10
9
|
useType,
|
|
11
10
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../../src/decorators/cookies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAsCpC,MAAM,UAAU,aAAa,CAAC,GAAG,IAAW;IAC1C,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,
|
|
1
|
+
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../../src/decorators/cookies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAsCpC,MAAM,UAAU,aAAa,CAAC,GAAG,IAAW;IAC1C,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AA6CD,MAAM,UAAU,OAAO,CAAC,GAAG,IAAW;IACpC,aAAa;IACb,OAAO,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@Cookies() cookies: any) {\n * console.log('Entire cookies', cookies);\n * }\n *\n * @Post('/')\n * create(@Cookies('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/')\n * create(@Cookies('user') user: IUser) {\n * console.log('user', user);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function CookiesParams(expression: string | any, useType: any): ParameterDecorator;\nexport function CookiesParams(): ParameterDecorator;\nexport function CookiesParams(expression: string | any): ParameterDecorator;\nexport function CookiesParams(options: ParamOptions<any>): ParameterDecorator;\nexport function CookiesParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.COOKIES,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@Cookies() body: any) {\n * console.log('Entire body', body);\n * }\n *\n * @Post('/')\n * create(@Cookies('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/')\n * create(@Cookies('user') user: User) { // with deserialization\n * console.log('user', user);\n * }\n *\n * @Post('/')\n * create(@Cookies('users', User) users: User[]) { // with deserialization\n * console.log('users', users);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @aliasof CookiesParams\n * @operation\n * @input\n */\nexport function Cookies(expression: string, useType: Type<any>): ParameterDecorator;\nexport function Cookies(expression: string): ParameterDecorator;\nexport function Cookies(useType: Type<any>): ParameterDecorator;\nexport function Cookies(options: Partial<ParamOptions>): ParameterDecorator;\nexport function Cookies(): ParameterDecorator;\nexport function Cookies(...args: any[]): ParameterDecorator {\n // @ts-ignore\n return CookiesParams(...args);\n}\n"]}
|
|
@@ -5,7 +5,6 @@ export function HeaderParams(...args) {
|
|
|
5
5
|
const { expression, useType, useConverter = false, useValidation = false } = mapParamsOptions(args);
|
|
6
6
|
return UseParam({
|
|
7
7
|
paramType: ParamTypes.HEADER,
|
|
8
|
-
dataPath: "$ctx.request.headers",
|
|
9
8
|
expression,
|
|
10
9
|
useType,
|
|
11
10
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headerParams.js","sourceRoot":"","sources":["../../../src/decorators/headerParams.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAkC3D,MAAM,UAAU,YAAY,CAAC,GAAG,IAAW;IACzC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,MAAM;QAC5B,
|
|
1
|
+
{"version":3,"file":"headerParams.js","sourceRoot":"","sources":["../../../src/decorators/headerParams.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAkC3D,MAAM,UAAU,YAAY,CAAC,GAAG,IAAW;IACzC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,MAAM;QAC5B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {UseParam} from \"./useParam\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\n\n/**\n * HeaderParams return the value from [`request.get()`](http://expressjs.com/en/4x/api.html#req.get) method.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@HeaderParams() body: any) {\n * console.log('Entire body', body);\n * }\n *\n * @Get('/')\n * get(@HeaderParams('x-token') token: string) {\n * console.log('token', id);\n * }\n * }\n * ```\n *\n * @param expression The path of the property to get.\n * @param useType\n * @decorator\n * @operation\n * @input\n */\nexport function HeaderParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function HeaderParams(expression: string): ParameterDecorator;\nexport function HeaderParams(useType: Type<any>): ParameterDecorator;\nexport function HeaderParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function HeaderParams(): ParameterDecorator;\nexport function HeaderParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.HEADER,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locals.js","sourceRoot":"","sources":["../../../src/decorators/locals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AA4CpC,MAAM,UAAU,MAAM,CAAC,GAAG,IAAW;IACnC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,MAAM;QAC5B,
|
|
1
|
+
{"version":3,"file":"locals.js","sourceRoot":"","sources":["../../../src/decorators/locals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AA4CpC,MAAM,UAAU,MAAM,CAAC,GAAG,IAAW;IACnC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,MAAM;QAC5B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Locals return the value from [response.locals](http://expressjs.com/en/4x/api.html#res.locals) object.\n *\n * ::: tip\n * Locals are generally used by express and third-party like templating engine to render a page/template.\n * See [Templating](http://tsed.io/tutorials/templating.html) section for more details.\n * :::\n *\n * #### Example\n *\n * ```typescript\n * * @Middleware()\n * class LocalsMiddleware {\n * use(@Locals() locals: any) {\n * // set some on locals\n * locals.user = \"user\"\n * }\n * }\n *\n * @Controller('/')\n * @UseBefore(LocalsMiddleware)\n * class MyCtrl {\n * @Get('/')\n * @View('home.ejs') // will use locals and returned data to render the page\n * get(@Locals('user') user: any) {\n * console.log('user', user);\n *\n * return {\n * description: 'Hello world'\n * }\n * }\n * }\n * ```\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport function Locals(expression: string): ParameterDecorator;\nexport function Locals(): ParameterDecorator;\nexport function Locals(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.LOCALS,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathParams.js","sourceRoot":"","sources":["../../../src/decorators/pathParams.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAuCpC,MAAM,UAAU,UAAU,CAAC,GAAG,IAAW;IACvC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,IAAI;QAC1B,
|
|
1
|
+
{"version":3,"file":"pathParams.js","sourceRoot":"","sources":["../../../src/decorators/pathParams.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAuCpC,MAAM,UAAU,UAAU,CAAC,GAAG,IAAW;IACvC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,IAAI;QAC1B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,IAAI;QAC1B,QAAQ,EAAE,qBAAqB;QAC/B,UAAU;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * PathParams return the value from [request.params](http://expressjs.com/en/4x/api.html#req.params) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@PathParams() params: any) {\n * console.log('Entire params', params);\n * }\n *\n * @Get('/')\n * get(@PathParams('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Get('/')\n * get(@PathParams({expression: 'id', useType: () => new MyCustomModel() }) id: string) {\n * console.log('ID', id);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function PathParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function PathParams(expression: string): ParameterDecorator;\nexport function PathParams(useType: Type<any>): ParameterDecorator;\nexport function PathParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function PathParams(): ParameterDecorator;\nexport function PathParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = true, useValidation = true} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.PATH,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * RawPathParams return the raw value from [request.params](http://expressjs.com/en/4x/api.html#req.params) object.\n *\n * Any validation and transformation are performed on the value. Use [pipes](/docs/pipes.html) to validate and/or transform the value.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@RawPathParams() params: string) {\n * console.log('Entire params', params);\n * }\n *\n * @Get('/')\n * get(@RawPathParams('id') id: string) {\n * console.log('ID', id);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function RawPathParams(expression: string) {\n return UseParam({\n paramType: ParamTypes.PATH,\n dataPath: \"$ctx.request.params\",\n expression\n });\n}\n"]}
|
|
@@ -5,7 +5,6 @@ export function QueryParams(...args) {
|
|
|
5
5
|
const { expression, useType, useConverter = true, useValidation = true } = mapParamsOptions(args);
|
|
6
6
|
return UseParam({
|
|
7
7
|
paramType: ParamTypes.QUERY,
|
|
8
|
-
dataPath: "$ctx.request.query",
|
|
9
8
|
expression,
|
|
10
9
|
useType,
|
|
11
10
|
useConverter,
|
|
@@ -41,10 +40,10 @@ export function QueryParams(...args) {
|
|
|
41
40
|
* @input
|
|
42
41
|
*/
|
|
43
42
|
export function RawQueryParams(expression) {
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
return QueryParams({
|
|
44
|
+
expression,
|
|
45
|
+
useConverters: false,
|
|
46
|
+
useValidation: false
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
//# sourceMappingURL=queryParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryParams.js","sourceRoot":"","sources":["../../../src/decorators/queryParams.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AA4CpC,MAAM,UAAU,WAAW,CAAC,GAAG,IAAW;IACxC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,KAAK;QAC3B,
|
|
1
|
+
{"version":3,"file":"queryParams.js","sourceRoot":"","sources":["../../../src/decorators/queryParams.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AA4CpC,MAAM,UAAU,WAAW,CAAC,GAAG,IAAW;IACxC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEhG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,KAAK;QAC3B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,OAAO,WAAW,CAAC;QACjB,UAAU;QACV,aAAa,EAAE,KAAK;QACpB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * QueryParams return the value from [request.query](http://expressjs.com/en/4x/api.html#req.query) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@QueryParams() query: any) {\n * console.log('Entire query', query);\n * }\n *\n * @Get('/')\n * get(@QueryParams('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Get('/')\n * get(@QueryParams('user') user: User) { // with deserialization\n * console.log('user', user);\n * }\n *\n * @Get('/')\n * get(@QueryParams('users', User) users: User[]) { // with deserialization\n * console.log('users', users);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @param useType The type of the class that to be used to deserialize the data.\n * @decorator\n * @operation\n * @input\n */\nexport function QueryParams(expression: string, useType: Type<any>): ParameterDecorator;\nexport function QueryParams(expression: string): ParameterDecorator;\nexport function QueryParams(useType: Type<any>): ParameterDecorator;\nexport function QueryParams(options: Partial<ParamOptions>): ParameterDecorator;\nexport function QueryParams(): ParameterDecorator;\nexport function QueryParams(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = true, useValidation = true} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.QUERY,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n\n/**\n * RawQueryParams return the value from [request.query](http://expressjs.com/en/4x/api.html#req.query) object.\n *\n * Any validation and transformation are performed on the value. Use [pipes](/docs/pipes.html) to validate and/or transform the value.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Get('/')\n * get(@RawPathParams() params: any) {\n * console.log('Entire params', params);\n * }\n *\n * @Get('/')\n * get(@RawPathParams('id') id: string) {\n * console.log('ID', id);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function RawQueryParams(expression: string) {\n return QueryParams({\n expression,\n useConverters: false,\n useValidation: false\n });\n}\n"]}
|
|
@@ -5,7 +5,6 @@ export function Session(...args) {
|
|
|
5
5
|
const { expression, useType, useConverter = false, useValidation = false } = mapParamsOptions(args);
|
|
6
6
|
return UseParam({
|
|
7
7
|
paramType: ParamTypes.SESSION,
|
|
8
|
-
dataPath: "$ctx.request.session",
|
|
9
8
|
expression,
|
|
10
9
|
useType,
|
|
11
10
|
useConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/decorators/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAqCpC,MAAM,UAAU,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/decorators/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAqCpC,MAAM,UAAU,OAAO,CAAC,GAAG,IAAW;IACpC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,UAAU;QACV,OAAO;QACP,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {mapParamsOptions} from \"../utils/mapParamsOptions\";\nimport {UseParam} from \"./useParam\";\n\n/**\n * Session return the value from [request.session](http://expressjs.com/en/4x/api.html#req.session) object.\n *\n * #### Example\n *\n * ```typescript\n * @Controller('/')\n * class MyCtrl {\n * @Post('/')\n * create(@Session() session: Express.Session) {\n * console.log('Entire session', session);\n * }\n *\n * @Post('/')\n * create(@Session('id') id: string) {\n * console.log('ID', id);\n * }\n *\n * @Post('/') // Example to deserialize use from session\n * create(@Session({expression: 'user', useConverter: true}) user: User) {\n * console.log('user', user);\n * console.log('instanceOf user', user instanceof User);\n * }\n * }\n * ```\n * > For more information on deserialization see [converters](/docs/converters.md) page.\n *\n * @param expression The path of the property to get.\n * @decorator\n * @operation\n * @input\n */\nexport function Session(expression: string): ParameterDecorator;\nexport function Session(options: Partial<ParamOptions>): ParameterDecorator;\nexport function Session(): ParameterDecorator;\nexport function Session(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return UseParam({\n paramType: ParamTypes.SESSION,\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAC,GAAG,EAAC,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,SAAS,QAAQ,CAAC,OAA8B;IAC9C,MAAM,EAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;IAExF,OAAO;QACL,OAAO;YACL,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;YAClB,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;gBAC7B,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,SAAS,KAAK,UAAU,CAAC,KAAK,EAAE;oBACnF,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC;iBACtB;YACH,CAAC,CAAC;QACN,aAAa,IAAI,aAAa,EAAE;QAChC,YAAY,IAAI,kBAAkB,CAAC,KAAK,CAAC;KAC1C,CAAC;AACJ,CAAC;AAuBD,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClD,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KAC3D,CAAC;IAEF,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AAC1F,CAAC","sourcesContent":["import {isBuffer, isString, useDecorators} from \"@tsed/core\";\nimport {Any} from \"@tsed/schema\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport {ParamFn} from \"./paramFn\";\nimport {UseDeserialization} from \"./useDeserialization\";\nimport {UseParamType} from \"./useParamType\";\nimport {UseType} from \"./useType\";\nimport {UseValidation} from \"./useValidation\";\n\n/**\n * @ignore\n * @param options\n */\nfunction mapPipes(options: Partial<ParamOptions>) {\n const {paramType, useType, expression, useValidation, useConverter, ...props} = options;\n\n return [\n useType\n ? UseType(useType)\n : ParamFn((entity, parameters) => {\n if (entity.isCollection && entity.type === Object && paramType !== ParamTypes.FILES) {\n Any()(...parameters);\n }\n }),\n useValidation && UseValidation(),\n useConverter && UseDeserialization(props)\n ];\n}\n\n/**\n * Register a new param. It use the paramType to extract value and give it to the next pipe.\n *\n * Given options allow to enable or disable following pipes:\n *\n * - useType: Add extra type for the json mapper,\n * - expression: Get property from the returned value by the previous pipe.\n * - useValidation: Apply validation from the returned value by the previous pipe.\n * - useConverter: Apply json mapper from the returned value by the previous pipe.\n *\n * @param options\n * @decorator\n * @operation\n * @input\n * @pipe\n */\nexport function UseParam(options: Partial<ParamOptions>): ParameterDecorator;\n/**\n * @deprecated Since v6\n */\nexport function UseParam(paramType: string, options?: Partial<ParamOptions>): ParameterDecorator;\nexport function UseParam(...args: any[]): ParameterDecorator {\n const options = {\n ...((isString(args[0]) ? args[1] : args[0]) || {}),\n paramType: isString(args[0]) ? args[0] : args[0].paramType\n };\n\n return useDecorators(UseParamType(options), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useDecorators } from "@tsed/core";
|
|
1
|
+
import { isBuffer, useDecorators } from "@tsed/core";
|
|
2
2
|
import { isParameterType, Name } from "@tsed/schema";
|
|
3
3
|
import { ParamFn } from "./paramFn.js";
|
|
4
4
|
import { UseParamExpression } from "./useParamExpression.js";
|
|
5
|
+
import { PARAM_TYPES_DATA_PATH, ParamTypes } from "../domain/ParamTypes.js";
|
|
5
6
|
/**
|
|
6
7
|
* Get the object from request (like body, params, query, etc...).
|
|
7
8
|
*
|
|
@@ -12,11 +13,16 @@ import { UseParamExpression } from "./useParamExpression.js";
|
|
|
12
13
|
*/
|
|
13
14
|
export function UseParamType(options) {
|
|
14
15
|
return useDecorators(ParamFn((param) => {
|
|
16
|
+
var _a;
|
|
15
17
|
if (isParameterType(options.paramType)) {
|
|
16
18
|
param.parameter.in(options.paramType);
|
|
17
19
|
}
|
|
18
20
|
param.paramType = options.paramType;
|
|
19
|
-
param.
|
|
20
|
-
|
|
21
|
+
if (isBuffer(param.type) || isBuffer(options.useType) || options.paramType === ParamTypes.RAW_BODY) {
|
|
22
|
+
param.paramType = ParamTypes.RAW_BODY;
|
|
23
|
+
(_a = param.parent.operation) === null || _a === void 0 ? void 0 : _a.consumes(["*/*"]);
|
|
24
|
+
}
|
|
25
|
+
param.dataPath = options.dataPath || PARAM_TYPES_DATA_PATH[param.paramType] || "$ctx";
|
|
26
|
+
}), options.expression && UseParamExpression(options.expression), options.expression && Name(options.expression));
|
|
21
27
|
}
|
|
22
28
|
//# sourceMappingURL=useParamType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParamType.js","sourceRoot":"","sources":["../../../src/decorators/useParamType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"useParamType.js","sourceRoot":"","sources":["../../../src/decorators/useParamType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,eAAe,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,qBAAqB,EAAE,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,OAAqB;IAChD,OAAO,aAAa,CAClB,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;;QAChB,IAAI,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACtC,KAAK,CAAC,SAAU,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SACxC;QAED,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAEpC,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,SAAS,KAAK,UAAU,CAAC,QAAQ,EAAE;YAClG,KAAK,CAAC,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC;YACtC,MAAA,KAAK,CAAC,MAAM,CAAC,SAAS,0CAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;SAC3C;QAED,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAqB,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC;IACxF,CAAC,CAAC,EACF,OAAO,CAAC,UAAU,IAAI,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,EAC5D,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import {isBuffer, useDecorators} from \"@tsed/core\";\nimport {isParameterType, Name} from \"@tsed/schema\";\nimport {ParamFn} from \"./paramFn\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {UseParamExpression} from \"./useParamExpression\";\nimport {PARAM_TYPES_DATA_PATH, ParamTypes} from \"../domain/ParamTypes\";\n\n/**\n * Get the object from request (like body, params, query, etc...).\n *\n * @decorator\n * @operation\n * @input\n * @pipe\n */\nexport function UseParamType(options: ParamOptions) {\n return useDecorators(\n ParamFn((param) => {\n if (isParameterType(options.paramType)) {\n param.parameter!.in(options.paramType);\n }\n\n param.paramType = options.paramType;\n\n if (isBuffer(param.type) || isBuffer(options.useType) || options.paramType === ParamTypes.RAW_BODY) {\n param.paramType = ParamTypes.RAW_BODY;\n param.parent.operation?.consumes([\"*/*\"]);\n }\n\n param.dataPath = options.dataPath || PARAM_TYPES_DATA_PATH[param.paramType] || \"$ctx\";\n }),\n options.expression && UseParamExpression(options.expression),\n options.expression && Name(options.expression)\n );\n}\n"]}
|
|
@@ -24,4 +24,14 @@ export var ParamTypes;
|
|
|
24
24
|
ParamTypes["RES"] = "RES";
|
|
25
25
|
ParamTypes["REQ"] = "REQ";
|
|
26
26
|
})(ParamTypes || (ParamTypes = {}));
|
|
27
|
+
export const PARAM_TYPES_DATA_PATH = {
|
|
28
|
+
[ParamTypes.HEADER]: "$ctx.request.headers",
|
|
29
|
+
[ParamTypes.RAW_BODY]: "$ctx.request.rawBody",
|
|
30
|
+
[ParamTypes.BODY]: "$ctx.request.body",
|
|
31
|
+
[ParamTypes.QUERY]: "$ctx.request.query",
|
|
32
|
+
[ParamTypes.PATH]: "$ctx.request.params",
|
|
33
|
+
[ParamTypes.COOKIES]: "$ctx.request.cookies",
|
|
34
|
+
[ParamTypes.SESSION]: "$ctx.request.session",
|
|
35
|
+
[ParamTypes.LOCALS]: "$ctx.response.locals"
|
|
36
|
+
};
|
|
27
37
|
//# sourceMappingURL=ParamTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParamTypes.js","sourceRoot":"","sources":["../../../src/domain/ParamTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAyBX;AAzBD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IAEf,WAAW;IACX,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,iCAAmB,CAAA;IACnB,mDAAqC,CAAA;IACrC,2CAA6B,CAAA;IAC7B,mCAAqB,CAAA;IACrB,qDAAuC,CAAA;IACvC,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,yBAAW,CAAA;IACX,yBAAW,CAAA;AACb,CAAC,EAzBW,UAAU,KAAV,UAAU,QAyBrB","sourcesContent":["export enum ParamTypes {\n $CTX = \"$CTX\",\n BODY = \"BODY\",\n PATH = \"PATH\",\n QUERY = \"QUERY\",\n HEADER = \"HEADER\",\n RAW_BODY = \"RAW_BODY\",\n COOKIES = \"COOKIES\",\n LOCALS = \"LOCALS\",\n SESSION = \"SESSION\",\n FILES = \"FILES\",\n\n /// NOT STD\n NEXT_FN = \"NEXT_FN\",\n ERR = \"ERR\",\n REQUEST = \"REQUEST\",\n PLATFORM_REQUEST = \"PLATFORM_REQUEST\",\n NODE_REQUEST = \"NODE_REQUEST\",\n RESPONSE = \"RESPONSE\",\n PLATFORM_RESPONSE = \"PLATFORM_RESPONSE\",\n NODE_RESPONSE = \"NODE_RESPONSE\",\n RESPONSE_DATA = \"RESPONSE_DATA\",\n ENDPOINT_INFO = \"ENDPOINT_INFO\",\n RES = \"RES\",\n REQ = \"REQ\"\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ParamTypes.js","sourceRoot":"","sources":["../../../src/domain/ParamTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAyBX;AAzBD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IAEf,WAAW;IACX,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,iCAAmB,CAAA;IACnB,mDAAqC,CAAA;IACrC,2CAA6B,CAAA;IAC7B,mCAAqB,CAAA;IACrB,qDAAuC,CAAA;IACvC,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,yBAAW,CAAA;IACX,yBAAW,CAAA;AACb,CAAC,EAzBW,UAAU,KAAV,UAAU,QAyBrB;AAED,MAAM,CAAC,MAAM,qBAAqB,GAA2B;IAC3D,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;IAC3C,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,sBAAsB;IAC7C,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,mBAAmB;IACtC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,oBAAoB;IACxC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,qBAAqB;IACxC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;CAC5C,CAAC","sourcesContent":["export enum ParamTypes {\n $CTX = \"$CTX\",\n BODY = \"BODY\",\n PATH = \"PATH\",\n QUERY = \"QUERY\",\n HEADER = \"HEADER\",\n RAW_BODY = \"RAW_BODY\",\n COOKIES = \"COOKIES\",\n LOCALS = \"LOCALS\",\n SESSION = \"SESSION\",\n FILES = \"FILES\",\n\n /// NOT STD\n NEXT_FN = \"NEXT_FN\",\n ERR = \"ERR\",\n REQUEST = \"REQUEST\",\n PLATFORM_REQUEST = \"PLATFORM_REQUEST\",\n NODE_REQUEST = \"NODE_REQUEST\",\n RESPONSE = \"RESPONSE\",\n PLATFORM_RESPONSE = \"PLATFORM_RESPONSE\",\n NODE_RESPONSE = \"NODE_RESPONSE\",\n RESPONSE_DATA = \"RESPONSE_DATA\",\n ENDPOINT_INFO = \"ENDPOINT_INFO\",\n RES = \"RES\",\n REQ = \"REQ\"\n}\n\nexport const PARAM_TYPES_DATA_PATH: Record<string, string> = {\n [ParamTypes.HEADER]: \"$ctx.request.headers\",\n [ParamTypes.RAW_BODY]: \"$ctx.request.rawBody\",\n [ParamTypes.BODY]: \"$ctx.request.body\",\n [ParamTypes.QUERY]: \"$ctx.request.query\",\n [ParamTypes.PATH]: \"$ctx.request.params\",\n [ParamTypes.COOKIES]: \"$ctx.request.cookies\",\n [ParamTypes.SESSION]: \"$ctx.request.session\",\n [ParamTypes.LOCALS]: \"$ctx.response.locals\"\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-params",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.111.0",
|
|
4
4
|
"description": "Params module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"tslib": "2.3.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@tsed/core": "6.
|
|
27
|
-
"@tsed/di": "6.
|
|
28
|
-
"@tsed/exceptions": "6.
|
|
29
|
-
"@tsed/json-mapper": "6.
|
|
30
|
-
"@tsed/schema": "6.
|
|
26
|
+
"@tsed/core": "6.111.0",
|
|
27
|
+
"@tsed/di": "6.111.0",
|
|
28
|
+
"@tsed/exceptions": "6.111.0",
|
|
29
|
+
"@tsed/json-mapper": "6.111.0",
|
|
30
|
+
"@tsed/schema": "6.111.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@tsed/core": "^6.
|
|
34
|
-
"@tsed/di": "^6.
|
|
35
|
-
"@tsed/exceptions": "^6.
|
|
36
|
-
"@tsed/json-mapper": "^6.
|
|
37
|
-
"@tsed/schema": "^6.
|
|
33
|
+
"@tsed/core": "^6.111.0",
|
|
34
|
+
"@tsed/di": "^6.111.0",
|
|
35
|
+
"@tsed/exceptions": "^6.111.0",
|
|
36
|
+
"@tsed/json-mapper": "^6.111.0",
|
|
37
|
+
"@tsed/schema": "^6.111.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@tsed/core": {
|