@tsed/platform-params 7.5.0 → 7.5.2
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/useParam.js +1 -13
- package/lib/cjs/decorators/useParam.js.map +1 -1
- package/lib/cjs/decorators/useType.js +12 -4
- package/lib/cjs/decorators/useType.js.map +1 -1
- package/lib/esm/decorators/useParam.js +1 -13
- package/lib/esm/decorators/useParam.js.map +1 -1
- package/lib/esm/decorators/useType.js +13 -5
- package/lib/esm/decorators/useType.js.map +1 -1
- package/lib/types/decorators/useType.d.ts +3 -3
- package/package.json +11 -11
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UseParam = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
|
-
const schema_1 = require("@tsed/schema");
|
|
6
5
|
const ParamTypes_1 = require("../domain/ParamTypes");
|
|
7
|
-
const paramFn_1 = require("./paramFn");
|
|
8
6
|
const useDeserialization_1 = require("./useDeserialization");
|
|
9
7
|
const useParamType_1 = require("./useParamType");
|
|
10
8
|
const useType_1 = require("./useType");
|
|
@@ -15,17 +13,7 @@ const useValidation_1 = require("./useValidation");
|
|
|
15
13
|
*/
|
|
16
14
|
function mapPipes(options) {
|
|
17
15
|
const { paramType, useType, expression, useValidation, useMapper, ...props } = options;
|
|
18
|
-
return [
|
|
19
|
-
useType
|
|
20
|
-
? (0, useType_1.UseType)(useType)
|
|
21
|
-
: (0, paramFn_1.ParamFn)((entity, parameters) => {
|
|
22
|
-
if (entity.isCollection && entity.type === Object && paramType !== ParamTypes_1.ParamTypes.FILES) {
|
|
23
|
-
(0, schema_1.Any)()(...parameters);
|
|
24
|
-
}
|
|
25
|
-
}),
|
|
26
|
-
useValidation && (0, useValidation_1.UseValidation)(),
|
|
27
|
-
useMapper && (0, useDeserialization_1.UseDeserialization)(props)
|
|
28
|
-
];
|
|
16
|
+
return [paramType !== ParamTypes_1.ParamTypes.FILES && (0, useType_1.UseType)(useType), useValidation && (0, useValidation_1.UseValidation)(), useMapper && (0, useDeserialization_1.UseDeserialization)(props)];
|
|
29
17
|
}
|
|
30
18
|
/**
|
|
31
19
|
* Register a new param. It use the paramType to extract value and give it to the next pipe.
|
|
@@ -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,qCAAyC;AAEzC,qDAAgD;AAChD,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,SAAS,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;IAErF,OAAO,CAAC,SAAS,KAAK,uBAAU,CAAC,KAAK,IAAI,IAAA,iBAAO,EAAC,OAAO,CAAC,EAAE,aAAa,IAAI,IAAA,6BAAa,GAAE,EAAE,SAAS,IAAI,IAAA,uCAAkB,EAAC,KAAK,CAAC,CAAC,CAAC;AACxI,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,QAAQ,CAAC,OAA8B;IACrD,OAAO,IAAA,oBAAa,EAAC,IAAA,2BAAY,EAAC,OAAc,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AACjG,CAAC;AAFD,4BAEC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\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, useMapper, ...props} = options;\n\n return [paramType !== ParamTypes.FILES && UseType(useType), useValidation && UseValidation(), useMapper && UseDeserialization(props)];\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 return useDecorators(UseParamType(options as any), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
|
|
@@ -2,19 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UseType = void 0;
|
|
4
4
|
const schema_1 = require("@tsed/schema");
|
|
5
|
+
const paramFn_1 = require("./paramFn");
|
|
5
6
|
/**
|
|
6
|
-
* Set the type of the item
|
|
7
|
+
* Set the type of the item collection.
|
|
7
8
|
*
|
|
8
9
|
* Prefer @@CollectionOf@@ usage.
|
|
9
10
|
*
|
|
10
|
-
* @param
|
|
11
|
+
* @param useType
|
|
11
12
|
* @decorator
|
|
12
13
|
* @operation
|
|
13
14
|
* @input
|
|
14
15
|
* @alias CollectionOf
|
|
15
16
|
*/
|
|
16
|
-
function UseType(
|
|
17
|
-
return (0,
|
|
17
|
+
function UseType(useType) {
|
|
18
|
+
return (0, paramFn_1.ParamFn)((entity, parameters) => {
|
|
19
|
+
if (useType) {
|
|
20
|
+
return (0, schema_1.CollectionOf)(useType);
|
|
21
|
+
}
|
|
22
|
+
if (entity.isCollection && entity.type === Object && [undefined, "object"].includes(entity.itemSchema.get("type"))) {
|
|
23
|
+
(0, schema_1.Any)()(...parameters);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
18
26
|
}
|
|
19
27
|
exports.UseType = UseType;
|
|
20
28
|
//# sourceMappingURL=useType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useType.js","sourceRoot":"","sources":["../../../src/decorators/useType.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"useType.js","sourceRoot":"","sources":["../../../src/decorators/useType.ts"],"names":[],"mappings":";;;AACA,yCAA+C;AAC/C,uCAAkC;AAElC;;;;;;;;;;GAUG;AACH,SAAgB,OAAO,CAAC,OAAoC;IAC1D,OAAO,IAAA,iBAAO,EAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;QACpC,IAAI,OAAO,EAAE;YACX,OAAO,IAAA,qBAAY,EAAC,OAAO,CAAC,CAAC;SAC9B;QAED,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE;YAClH,IAAA,YAAG,GAAE,CAAC,GAAG,UAAU,CAAC,CAAC;SACtB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,0BAUC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Any, CollectionOf} from \"@tsed/schema\";\nimport {ParamFn} from \"./paramFn\";\n\n/**\n * Set the type of the item collection.\n *\n * Prefer @@CollectionOf@@ usage.\n *\n * @param useType\n * @decorator\n * @operation\n * @input\n * @alias CollectionOf\n */\nexport function UseType(useType: undefined | any | Type<any>) {\n return ParamFn((entity, parameters) => {\n if (useType) {\n return CollectionOf(useType);\n }\n\n if (entity.isCollection && entity.type === Object && [undefined, \"object\"].includes(entity.itemSchema.get(\"type\"))) {\n Any()(...parameters);\n }\n });\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useDecorators } from "@tsed/core";
|
|
2
|
-
import { Any } from "@tsed/schema";
|
|
3
2
|
import { ParamTypes } from "../domain/ParamTypes.js";
|
|
4
|
-
import { ParamFn } from "./paramFn.js";
|
|
5
3
|
import { UseDeserialization } from "./useDeserialization.js";
|
|
6
4
|
import { UseParamType } from "./useParamType.js";
|
|
7
5
|
import { UseType } from "./useType.js";
|
|
@@ -12,17 +10,7 @@ import { UseValidation } from "./useValidation.js";
|
|
|
12
10
|
*/
|
|
13
11
|
function mapPipes(options) {
|
|
14
12
|
const { paramType, useType, expression, useValidation, useMapper, ...props } = options;
|
|
15
|
-
return [
|
|
16
|
-
useType
|
|
17
|
-
? UseType(useType)
|
|
18
|
-
: ParamFn((entity, parameters) => {
|
|
19
|
-
if (entity.isCollection && entity.type === Object && paramType !== ParamTypes.FILES) {
|
|
20
|
-
Any()(...parameters);
|
|
21
|
-
}
|
|
22
|
-
}),
|
|
23
|
-
useValidation && UseValidation(),
|
|
24
|
-
useMapper && UseDeserialization(props)
|
|
25
|
-
];
|
|
13
|
+
return [paramType !== ParamTypes.FILES && UseType(useType), useValidation && UseValidation(), useMapper && UseDeserialization(props)];
|
|
26
14
|
}
|
|
27
15
|
/**
|
|
28
16
|
* Register a new param. It use the paramType to extract value and give it to the next pipe.
|
|
@@ -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,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,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,SAAS,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;IAErF,OAAO,CAAC,SAAS,KAAK,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,aAAa,IAAI,aAAa,EAAE,EAAE,SAAS,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;AACxI,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CAAC,OAA8B;IACrD,OAAO,aAAa,CAAC,YAAY,CAAC,OAAc,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AACjG,CAAC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\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, useMapper, ...props} = options;\n\n return [paramType !== ParamTypes.FILES && UseType(useType), useValidation && UseValidation(), useMapper && UseDeserialization(props)];\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 return useDecorators(UseParamType(options as any), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { CollectionOf } from "@tsed/schema";
|
|
1
|
+
import { Any, CollectionOf } from "@tsed/schema";
|
|
2
|
+
import { ParamFn } from "./paramFn.js";
|
|
2
3
|
/**
|
|
3
|
-
* Set the type of the item
|
|
4
|
+
* Set the type of the item collection.
|
|
4
5
|
*
|
|
5
6
|
* Prefer @@CollectionOf@@ usage.
|
|
6
7
|
*
|
|
7
|
-
* @param
|
|
8
|
+
* @param useType
|
|
8
9
|
* @decorator
|
|
9
10
|
* @operation
|
|
10
11
|
* @input
|
|
11
12
|
* @alias CollectionOf
|
|
12
13
|
*/
|
|
13
|
-
export function UseType(
|
|
14
|
-
return
|
|
14
|
+
export function UseType(useType) {
|
|
15
|
+
return ParamFn((entity, parameters) => {
|
|
16
|
+
if (useType) {
|
|
17
|
+
return CollectionOf(useType);
|
|
18
|
+
}
|
|
19
|
+
if (entity.isCollection && entity.type === Object && [undefined, "object"].includes(entity.itemSchema.get("type"))) {
|
|
20
|
+
Any()(...parameters);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
15
23
|
}
|
|
16
24
|
//# sourceMappingURL=useType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useType.js","sourceRoot":"","sources":["../../../src/decorators/useType.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useType.js","sourceRoot":"","sources":["../../../src/decorators/useType.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,OAAO,CAAC,OAAoC;IAC1D,OAAO,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;QACpC,IAAI,OAAO,EAAE;YACX,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;SAC9B;QAED,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE;YAClH,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC;SACtB;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Any, CollectionOf} from \"@tsed/schema\";\nimport {ParamFn} from \"./paramFn\";\n\n/**\n * Set the type of the item collection.\n *\n * Prefer @@CollectionOf@@ usage.\n *\n * @param useType\n * @decorator\n * @operation\n * @input\n * @alias CollectionOf\n */\nexport function UseType(useType: undefined | any | Type<any>) {\n return ParamFn((entity, parameters) => {\n if (useType) {\n return CollectionOf(useType);\n }\n\n if (entity.isCollection && entity.type === Object && [undefined, \"object\"].includes(entity.itemSchema.get(\"type\"))) {\n Any()(...parameters);\n }\n });\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
2
|
/**
|
|
3
|
-
* Set the type of the item
|
|
3
|
+
* Set the type of the item collection.
|
|
4
4
|
*
|
|
5
5
|
* Prefer @@CollectionOf@@ usage.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param useType
|
|
8
8
|
* @decorator
|
|
9
9
|
* @operation
|
|
10
10
|
* @input
|
|
11
11
|
* @alias CollectionOf
|
|
12
12
|
*/
|
|
13
|
-
export declare function UseType(
|
|
13
|
+
export declare function UseType(useType: undefined | any | Type<any>): ParameterDecorator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-params",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.2",
|
|
4
4
|
"description": "Params module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
"tslib": "2.4.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tsed/core": "7.5.
|
|
28
|
-
"@tsed/di": "7.5.
|
|
29
|
-
"@tsed/exceptions": "7.5.
|
|
30
|
-
"@tsed/json-mapper": "7.5.
|
|
31
|
-
"@tsed/schema": "7.5.
|
|
27
|
+
"@tsed/core": "7.5.2",
|
|
28
|
+
"@tsed/di": "7.5.2",
|
|
29
|
+
"@tsed/exceptions": "7.5.2",
|
|
30
|
+
"@tsed/json-mapper": "7.5.2",
|
|
31
|
+
"@tsed/schema": "7.5.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@tsed/core": "^7.5.
|
|
35
|
-
"@tsed/di": "^7.5.
|
|
36
|
-
"@tsed/exceptions": "^7.5.
|
|
37
|
-
"@tsed/json-mapper": "^7.5.
|
|
38
|
-
"@tsed/schema": "^7.5.
|
|
34
|
+
"@tsed/core": "^7.5.2",
|
|
35
|
+
"@tsed/di": "^7.5.2",
|
|
36
|
+
"@tsed/exceptions": "^7.5.2",
|
|
37
|
+
"@tsed/json-mapper": "^7.5.2",
|
|
38
|
+
"@tsed/schema": "^7.5.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@tsed/core": {
|