@tsed/platform-params 6.97.1 → 7.0.0-beta.1

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.
@@ -27,11 +27,26 @@ function mapPipes(options) {
27
27
  useConverter && (0, useDeserialization_1.UseDeserialization)(props)
28
28
  ];
29
29
  }
30
- function UseParam(...args) {
31
- const options = {
30
+ /**
31
+ * Register a new param. It use the paramType to extract value and give it to the next pipe.
32
+ *
33
+ * Given options allow to enable or disable following pipes:
34
+ *
35
+ * - useType: Add extra type for the json mapper,
36
+ * - expression: Get property from the returned value by the previous pipe.
37
+ * - useValidation: Apply validation from the returned value by the previous pipe.
38
+ * - useConverter: Apply json mapper from the returned value by the previous pipe.
39
+ *
40
+ * @param options
41
+ * @decorator
42
+ * @operation
43
+ * @input
44
+ * @pipe
45
+ */
46
+ function UseParam(options) {
47
+ options = {
32
48
  dataPath: "$ctx",
33
- ...(((0, core_1.isString)(args[0]) ? args[1] : args[0]) || {}),
34
- paramType: (0, core_1.isString)(args[0]) ? args[0] : args[0].paramType
49
+ ...options
35
50
  };
36
51
  return (0, core_1.useDecorators)((0, useParamType_1.UseParamType)(options), ...mapPipes(options));
37
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,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,QAAQ,EAAE,MAAM;QAChB,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;AARD,4BAQC","sourcesContent":["import {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 dataPath: \"$ctx\",\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
+ {"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,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;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,QAAQ,CAAC,OAA8B;IACrD,OAAO,GAAG;QACR,QAAQ,EAAE,MAAM;QAChB,GAAG,OAAO;KACX,CAAC;IAEF,OAAO,IAAA,oBAAa,EAAC,IAAA,2BAAY,EAAC,OAAc,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AACjG,CAAC;AAPD,4BAOC","sourcesContent":["import {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 options = {\n dataPath: \"$ctx\",\n ...options\n };\n\n return useDecorators(UseParamType(options as any), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { isString, useDecorators } from "@tsed/core";
1
+ import { useDecorators } from "@tsed/core";
2
2
  import { Any } from "@tsed/schema";
3
3
  import { ParamTypes } from "../domain/ParamTypes";
4
4
  import { ParamFn } from "./paramFn";
@@ -24,11 +24,26 @@ function mapPipes(options) {
24
24
  useConverter && UseDeserialization(props)
25
25
  ];
26
26
  }
27
- export function UseParam(...args) {
28
- const options = {
27
+ /**
28
+ * Register a new param. It use the paramType to extract value and give it to the next pipe.
29
+ *
30
+ * Given options allow to enable or disable following pipes:
31
+ *
32
+ * - useType: Add extra type for the json mapper,
33
+ * - expression: Get property from the returned value by the previous pipe.
34
+ * - useValidation: Apply validation from the returned value by the previous pipe.
35
+ * - useConverter: Apply json mapper from the returned value by the previous pipe.
36
+ *
37
+ * @param options
38
+ * @decorator
39
+ * @operation
40
+ * @input
41
+ * @pipe
42
+ */
43
+ export function UseParam(options) {
44
+ options = {
29
45
  dataPath: "$ctx",
30
- ...((isString(args[0]) ? args[1] : args[0]) || {}),
31
- paramType: isString(args[0]) ? args[0] : args[0].paramType
46
+ ...options
32
47
  };
33
48
  return useDecorators(UseParamType(options), ...mapPipes(options));
34
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,GAAG,EAAC,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM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AEF,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AAC1F,CAAC","sourcesContent":["import {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 dataPath: \"$ctx\",\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
+ {"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":"AAAA,OAA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ators} 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 options = {\n dataPath: \"$ctx\",\n ...options\n };\n\n return useDecorators(UseParamType(options as any), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
@@ -16,7 +16,3 @@ import { ParamOptions } from "../domain/ParamOptions";
16
16
  * @pipe
17
17
  */
18
18
  export declare function UseParam(options: Partial<ParamOptions>): ParameterDecorator;
19
- /**
20
- * @deprecated Since v6
21
- */
22
- export declare function UseParam(paramType: string, options?: Partial<ParamOptions>): ParameterDecorator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-params",
3
- "version": "6.97.1",
3
+ "version": "7.0.0-beta.1",
4
4
  "description": "Params module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -21,24 +21,24 @@
21
21
  "tslib": "2.2.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@tsed/core": "6.97.1",
25
- "@tsed/di": "6.97.1",
26
- "@tsed/exceptions": "6.97.1",
27
- "@tsed/json-mapper": "6.97.1",
28
- "@tsed/schema": "6.97.1"
24
+ "@tsed/core": "7.0.0-beta.1",
25
+ "@tsed/di": "7.0.0-beta.1",
26
+ "@tsed/exceptions": "7.0.0-beta.1",
27
+ "@tsed/json-mapper": "7.0.0-beta.1",
28
+ "@tsed/schema": "7.0.0-beta.1"
29
29
  },
30
30
  "peerDependencies": {
31
- "@tsed/core": "^6.97.1",
32
- "@tsed/di": "^6.97.1",
33
- "@tsed/exceptions": "^6.97.1",
34
- "@tsed/json-mapper": "^6.97.1",
35
- "@tsed/schema": "^6.97.1"
31
+ "@tsed/core": "^7.0.0-beta.1",
32
+ "@tsed/di": "^7.0.0-beta.1",
33
+ "@tsed/exceptions": "^7.0.0-beta.1",
34
+ "@tsed/json-mapper": "^7.0.0-beta.1",
35
+ "@tsed/schema": "^7.0.0-beta.1"
36
36
  },
37
37
  "repository": "https://github.com/tsedio/tsed",
38
38
  "bugs": {
39
39
  "url": "https://github.com/tsedio/tsed/issues"
40
40
  },
41
- "homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-params",
41
+ "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/platform-params",
42
42
  "author": "Romain Lenzotti",
43
43
  "license": "MIT"
44
44
  }