@tsed/platform-params 7.0.0-beta.3 → 7.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/lib/cjs/builder/PlatformParams.js +3 -3
  2. package/lib/cjs/builder/PlatformParams.js.map +1 -1
  3. package/lib/cjs/decorators/bodyParams.js +3 -10
  4. package/lib/cjs/decorators/bodyParams.js.map +1 -1
  5. package/lib/cjs/decorators/context.js +0 -1
  6. package/lib/cjs/decorators/context.js.map +1 -1
  7. package/lib/cjs/decorators/cookies.js +0 -1
  8. package/lib/cjs/decorators/cookies.js.map +1 -1
  9. package/lib/cjs/decorators/headerParams.js +0 -1
  10. package/lib/cjs/decorators/headerParams.js.map +1 -1
  11. package/lib/cjs/decorators/locals.js +0 -1
  12. package/lib/cjs/decorators/locals.js.map +1 -1
  13. package/lib/cjs/decorators/paramFn.js +2 -7
  14. package/lib/cjs/decorators/paramFn.js.map +1 -1
  15. package/lib/cjs/decorators/pathParams.js +0 -1
  16. package/lib/cjs/decorators/pathParams.js.map +1 -1
  17. package/lib/cjs/decorators/queryParams.js +4 -5
  18. package/lib/cjs/decorators/queryParams.js.map +1 -1
  19. package/lib/cjs/decorators/session.js +0 -1
  20. package/lib/cjs/decorators/session.js.map +1 -1
  21. package/lib/cjs/decorators/useParam.js +0 -4
  22. package/lib/cjs/decorators/useParam.js.map +1 -1
  23. package/lib/cjs/decorators/useParamType.js +8 -2
  24. package/lib/cjs/decorators/useParamType.js.map +1 -1
  25. package/lib/cjs/decorators/usePipe.js.map +1 -1
  26. package/lib/cjs/domain/ParamMetadata.js +2 -30
  27. package/lib/cjs/domain/ParamMetadata.js.map +1 -1
  28. package/lib/cjs/domain/ParamTypes.js +11 -1
  29. package/lib/cjs/domain/ParamTypes.js.map +1 -1
  30. package/lib/cjs/errors/ParamValidationError.js.map +1 -1
  31. package/lib/cjs/errors/RequiredValidationError.js.map +1 -1
  32. package/lib/cjs/exports.js +3 -0
  33. package/lib/cjs/exports.js.map +1 -0
  34. package/lib/cjs/index.js +31 -33
  35. package/lib/cjs/index.js.map +1 -1
  36. package/lib/cjs/package.json +3 -0
  37. package/lib/cjs/pipes/DeserializerPipe.js +3 -3
  38. package/lib/cjs/pipes/DeserializerPipe.js.map +1 -1
  39. package/lib/cjs/pipes/ParseExpressionPipe.js +10 -2
  40. package/lib/cjs/pipes/ParseExpressionPipe.js.map +1 -1
  41. package/lib/cjs/pipes/ValidationPipe.js +2 -2
  42. package/lib/cjs/pipes/ValidationPipe.js.map +1 -1
  43. package/lib/esm/builder/PlatformParams.js +2 -2
  44. package/lib/esm/builder/PlatformParams.js.map +1 -1
  45. package/lib/esm/decorators/bodyParams.js +6 -13
  46. package/lib/esm/decorators/bodyParams.js.map +1 -1
  47. package/lib/esm/decorators/context.js +3 -4
  48. package/lib/esm/decorators/context.js.map +1 -1
  49. package/lib/esm/decorators/cookies.js +3 -4
  50. package/lib/esm/decorators/cookies.js.map +1 -1
  51. package/lib/esm/decorators/headerParams.js +3 -4
  52. package/lib/esm/decorators/headerParams.js.map +1 -1
  53. package/lib/esm/decorators/locals.js +3 -4
  54. package/lib/esm/decorators/locals.js.map +1 -1
  55. package/lib/esm/decorators/paramFn.js +2 -7
  56. package/lib/esm/decorators/paramFn.js.map +1 -1
  57. package/lib/esm/decorators/pathParams.js +3 -4
  58. package/lib/esm/decorators/pathParams.js.map +1 -1
  59. package/lib/esm/decorators/queryParams.js +7 -8
  60. package/lib/esm/decorators/queryParams.js.map +1 -1
  61. package/lib/esm/decorators/session.js +3 -4
  62. package/lib/esm/decorators/session.js.map +1 -1
  63. package/lib/esm/decorators/useDeserialization.js +2 -2
  64. package/lib/esm/decorators/useParam.js +6 -10
  65. package/lib/esm/decorators/useParam.js.map +1 -1
  66. package/lib/esm/decorators/useParamExpression.js +1 -1
  67. package/lib/esm/decorators/useParamType.js +11 -5
  68. package/lib/esm/decorators/useParamType.js.map +1 -1
  69. package/lib/esm/decorators/usePipe.js +1 -1
  70. package/lib/esm/decorators/usePipe.js.map +1 -1
  71. package/lib/esm/decorators/useValidation.js +2 -2
  72. package/lib/esm/domain/ParamMetadata.js +1 -30
  73. package/lib/esm/domain/ParamMetadata.js.map +1 -1
  74. package/lib/esm/domain/ParamTypes.js +10 -0
  75. package/lib/esm/domain/ParamTypes.js.map +1 -1
  76. package/lib/esm/errors/ParamValidationError.js +1 -1
  77. package/lib/esm/errors/ParamValidationError.js.map +1 -1
  78. package/lib/esm/errors/RequiredValidationError.js +1 -1
  79. package/lib/esm/errors/RequiredValidationError.js.map +1 -1
  80. package/lib/esm/exports.js +2 -0
  81. package/lib/esm/exports.js.map +1 -0
  82. package/lib/esm/index.js +31 -33
  83. package/lib/esm/index.js.map +1 -1
  84. package/lib/esm/package.json +3 -0
  85. package/lib/esm/pipes/DeserializerPipe.js.map +1 -1
  86. package/lib/esm/pipes/ParseExpressionPipe.js +10 -2
  87. package/lib/esm/pipes/ParseExpressionPipe.js.map +1 -1
  88. package/lib/esm/pipes/ValidationPipe.js +2 -2
  89. package/lib/esm/pipes/ValidationPipe.js.map +1 -1
  90. package/lib/types/builder/PlatformParams.d.ts +3 -4
  91. package/lib/types/decorators/bodyParams.d.ts +1 -0
  92. package/lib/types/decorators/context.d.ts +0 -6
  93. package/lib/types/decorators/paramFn.d.ts +2 -2
  94. package/lib/types/decorators/usePipe.d.ts +1 -1
  95. package/lib/types/domain/ParamMetadata.d.ts +1 -16
  96. package/lib/types/domain/ParamTypes.d.ts +1 -0
  97. package/lib/types/errors/ParamValidationError.d.ts +2 -2
  98. package/lib/types/errors/RequiredValidationError.d.ts +2 -2
  99. package/lib/types/exports.d.ts +1 -0
  100. package/lib/types/index.d.ts +24 -21
  101. package/lib/types/pipes/DeserializerPipe.d.ts +2 -2
  102. package/lib/types/pipes/ParseExpressionPipe.d.ts +3 -2
  103. package/lib/types/pipes/ValidationPipe.d.ts +5 -5
  104. package/package.json +34 -15
  105. package/readme.md +1 -2
  106. package/tsconfig.compile.esm.json +1 -12
@@ -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,QAAQ,EAAE,sBAAsB;QAChC,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 dataPath: \"$ctx.request.session\",\n expression,\n useType,\n useConverter,\n useValidation\n });\n}\n"]}
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,5 +1,5 @@
1
- import { DeserializerPipe } from "../pipes/DeserializerPipe";
2
- import { UsePipe } from "./usePipe";
1
+ import { DeserializerPipe } from "../pipes/DeserializerPipe.js";
2
+ import { UsePipe } from "./usePipe.js";
3
3
  /**
4
4
  * Use JsonMapper to deserialize the data.
5
5
  *
@@ -1,11 +1,11 @@
1
1
  import { useDecorators } from "@tsed/core";
2
2
  import { Any } from "@tsed/schema";
3
- import { ParamTypes } from "../domain/ParamTypes";
4
- import { ParamFn } from "./paramFn";
5
- import { UseDeserialization } from "./useDeserialization";
6
- import { UseParamType } from "./useParamType";
7
- import { UseType } from "./useType";
8
- import { UseValidation } from "./useValidation";
3
+ import { ParamTypes } from "../domain/ParamTypes.js";
4
+ import { ParamFn } from "./paramFn.js";
5
+ import { UseDeserialization } from "./useDeserialization.js";
6
+ import { UseParamType } from "./useParamType.js";
7
+ import { UseType } from "./useType.js";
8
+ import { UseValidation } from "./useValidation.js";
9
9
  /**
10
10
  * @ignore
11
11
  * @param options
@@ -41,10 +41,6 @@ function mapPipes(options) {
41
41
  * @pipe
42
42
  */
43
43
  export function UseParam(options) {
44
- options = {
45
- dataPath: "$ctx",
46
- ...options
47
- };
48
44
  return useDecorators(UseParamType(options), ...mapPipes(options));
49
45
  }
50
46
  //# sourceMappingURL=useParam.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,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,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;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CAAC,OAA8B;IACrD,OAAO,GAAG;QACR,QAAQ,EAAE,MAAM;QAChB,GAAG,OAAO;KACX,CAAC;IAEF,OAAO,aAAa,CAAC,YAAY,CAAC,OAAc,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AACjG,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 options = {\n dataPath: \"$ctx\",\n ...options\n };\n\n return useDecorators(UseParamType(options as any), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
1
+ {"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,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;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 {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 return useDecorators(UseParamType(options as any), ...mapPipes(options)) as ParameterDecorator;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { ParamFn } from "./paramFn";
1
+ import { ParamFn } from "./paramFn.js";
2
2
  /**
3
3
  * Get data from a path inside the given object
4
4
  *
@@ -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
- import { ParamFn } from "./paramFn";
4
- import { UseParamExpression } from "./useParamExpression";
3
+ import { ParamFn } from "./paramFn.js";
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";
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.dataPath = options.dataPath;
20
- }), UseParamExpression(options.expression), options.expression && Name(options.expression));
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;AACzC,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;AAExD;;;;;;;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;QACpC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IACpC,CAAC,CAAC,EACF,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,EACtC,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {isParameterType, Name} from \"@tsed/schema\";\nimport {ParamFn} from \"./paramFn\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\nimport {UseParamExpression} from \"./useParamExpression\";\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 param.dataPath = options.dataPath;\n }),\n UseParamExpression(options.expression),\n options.expression && Name(options.expression)\n );\n}\n"]}
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"]}
@@ -1,4 +1,4 @@
1
- import { ParamFn } from "./paramFn";
1
+ import { ParamFn } from "./paramFn.js";
2
2
  /**
3
3
  * Register a Pipe to be used with the current decorated param.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"usePipe.js","sourceRoot":"","sources":["../../../src/decorators/usePipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAAC,KAAwB,EAAE,UAAe,EAAE;IACjE,OAAO,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAChC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PipeMethods} from \"../domain/ParamMetadata\";\nimport {ParamFn} from \"./paramFn\";\n\n/**\n * Register a Pipe to be used with the current decorated param.\n *\n * @param token\n * @param options\n * @decorator\n * @operation\n * @input\n * @pipe\n */\nexport function UsePipe(token: Type<PipeMethods>, options: any = {}) {\n return ParamFn((param) => {\n param.store.set(token, options);\n param.pipes.push(token);\n });\n}\n"]}
1
+ {"version":3,"file":"usePipe.js","sourceRoot":"","sources":["../../../src/decorators/usePipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAAC,KAAwB,EAAE,UAAe,EAAE;IACjE,OAAO,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAChC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PipeMethods} from \"@tsed/schema\";\nimport {ParamFn} from \"./paramFn\";\n\n/**\n * Register a Pipe to be used with the current decorated param.\n *\n * @param token\n * @param options\n * @decorator\n * @operation\n * @input\n * @pipe\n */\nexport function UsePipe(token: Type<PipeMethods>, options: any = {}) {\n return ParamFn((param) => {\n param.store.set(token, options);\n param.pipes.push(token);\n });\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { ValidationPipe } from "../pipes/ValidationPipe";
2
- import { ParamFn } from "./paramFn";
1
+ import { ValidationPipe } from "../pipes/ValidationPipe.js";
2
+ import { ParamFn } from "./paramFn.js";
3
3
  /**
4
4
  * Enable validation on the decoratored parameter.
5
5
  *
@@ -1,31 +1,2 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { DecoratorTypes, prototypeOf } from "@tsed/core";
3
- import { JsonEntityComponent, JsonEntityStore, JsonParameterStore } from "@tsed/schema";
4
- import { ParamTypes } from "./ParamTypes";
5
- let ParamMetadata = class ParamMetadata extends JsonParameterStore {
6
- constructor(options) {
7
- super(options);
8
- this.paramType = "$ctx";
9
- this.pipes = [];
10
- this.paramType = options.paramType || this.paramType;
11
- this.expression = options.expression || this.expression;
12
- this.dataPath = options.dataPath || this.dataPath;
13
- this.pipes = options.pipes || [];
14
- }
15
- get key() {
16
- let { expression, paramType, dataPath } = this;
17
- if (expression && paramType === ParamTypes.HEADER) {
18
- expression = String(expression).toLowerCase();
19
- }
20
- return [dataPath, expression].filter(Boolean).join(".");
21
- }
22
- static get(target, propertyKey, index) {
23
- return JsonEntityStore.from(prototypeOf(target), propertyKey, index);
24
- }
25
- };
26
- ParamMetadata = __decorate([
27
- JsonEntityComponent(DecoratorTypes.PARAM),
28
- __metadata("design:paramtypes", [Object])
29
- ], ParamMetadata);
30
- export { ParamMetadata };
1
+ export { ParamMetadata } from "@tsed/schema";
31
2
  //# sourceMappingURL=ParamMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ParamMetadata.js","sourceRoot":"","sources":["../../../src/domain/ParamMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAA0B,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAE9G,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AASxC,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,kBAAkB;IAMnD,YAAY,OAAgC;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QAJV,cAAS,GAAW,MAAM,CAAC;QAC3B,UAAK,GAAwB,EAAE,CAAC;QAIrC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,GAAG;QACL,IAAI,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;QAE7C,IAAI,UAAU,IAAI,SAAS,KAAK,UAAU,CAAC,MAAM,EAAE;YACjD,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;SAC/C;QAED,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B,EAAE,KAAa;QACvE,OAAO,eAAe,CAAC,IAAI,CAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IACtF,CAAC;CACF,CAAA;AA3BY,aAAa;IADzB,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC;;GAC7B,aAAa,CA2BzB;SA3BY,aAAa","sourcesContent":["import {DecoratorTypes, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityComponent, JsonEntityStore, JsonEntityStoreOptions, JsonParameterStore} from \"@tsed/schema\";\nimport {ParamOptions} from \"./ParamOptions\";\nimport {ParamTypes} from \"./ParamTypes\";\n\nexport interface PipeMethods<T = any, R = any> {\n transform(value: T, metadata: ParamMetadata): R;\n}\n\nexport type ParamConstructorOptions = JsonEntityStoreOptions & ParamOptions;\n\n@JsonEntityComponent(DecoratorTypes.PARAM)\nexport class ParamMetadata extends JsonParameterStore implements ParamConstructorOptions {\n public expression: string;\n public dataPath: string;\n public paramType: string = \"$ctx\";\n public pipes: Type<PipeMethods>[] = [];\n\n constructor(options: ParamConstructorOptions) {\n super(options);\n this.paramType = options.paramType || this.paramType;\n this.expression = options.expression || this.expression;\n this.dataPath = options.dataPath || this.dataPath;\n this.pipes = options.pipes || [];\n }\n\n get key() {\n let {expression, paramType, dataPath} = this;\n\n if (expression && paramType === ParamTypes.HEADER) {\n expression = String(expression).toLowerCase();\n }\n\n return [dataPath, expression].filter(Boolean).join(\".\");\n }\n\n static get(target: Type<any>, propertyKey: string | symbol, index: number): ParamMetadata {\n return JsonEntityStore.from<ParamMetadata>(prototypeOf(target), propertyKey, index);\n }\n}\n"]}
1
+ {"version":3,"file":"ParamMetadata.js","sourceRoot":"","sources":["../../../src/domain/ParamMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC","sourcesContent":["export {ParamMetadata} from \"@tsed/schema\";\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"]}
@@ -1,6 +1,6 @@
1
1
  import { nameOf } from "@tsed/core";
2
2
  import { BadRequest } from "@tsed/exceptions";
3
- import { ValidationError } from "./ValidationError";
3
+ import { ValidationError } from "./ValidationError.js";
4
4
  export class ParamValidationError extends BadRequest {
5
5
  constructor() {
6
6
  super(...arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"ParamValidationError.js","sourceRoot":"","sources":["../../../src/errors/ParamValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAApD;;QACS,SAAI,GAAW,wBAAwB,CAAC;IAsBjD,CAAC;IAlBC,MAAM,CAAC,IAAI,CAAC,QAAuB,EAAE,SAAc,EAAE;QACnD,IAAI,MAAM,YAAY,eAAe,IAAI,MAAM,YAAY,UAAU,EAAE;YACrE,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;iBACpC,WAAW,EAAE;iBACb,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;YACvC,MAAM,OAAO,GAAG,qCAAqC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YAE7H,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAChD,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACnD,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC/C,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC;YAEvC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import {nameOf} from \"@tsed/core\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {ParamMetadata} from \"../domain/ParamMetadata\";\nimport {ValidationError} from \"./ValidationError\";\n\nexport class ParamValidationError extends BadRequest {\n public name: string = \"PARAM_VALIDATION_ERROR\";\n public dataPath: string;\n public requestType: string;\n\n static from(metadata: ParamMetadata, origin: any = {}) {\n if (origin instanceof ValidationError || origin instanceof BadRequest) {\n const name = nameOf(metadata.paramType)\n .toLowerCase()\n .replace(/parse|params|filter/gi, \"\");\n const expression = metadata.expression;\n const message = `Bad request on parameter \"request.${name}${expression ? \".\" + expression : \"\"}\".\\n${origin.message}`.trim();\n\n const error = new ParamValidationError(message);\n error.dataPath = String(metadata.expression) || \"\";\n error.requestType = nameOf(metadata.paramType);\n error.origin = origin.origin || origin;\n\n return error;\n }\n\n return origin;\n }\n}\n"]}
1
+ {"version":3,"file":"ParamValidationError.js","sourceRoot":"","sources":["../../../src/errors/ParamValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAApD;;QACS,SAAI,GAAW,wBAAwB,CAAC;IAsBjD,CAAC;IAlBC,MAAM,CAAC,IAAI,CAAC,QAA4B,EAAE,SAAc,EAAE;QACxD,IAAI,MAAM,YAAY,eAAe,IAAI,MAAM,YAAY,UAAU,EAAE;YACrE,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;iBACpC,WAAW,EAAE;iBACb,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;YACvC,MAAM,OAAO,GAAG,qCAAqC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YAE7H,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAChD,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACnD,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC/C,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC;YAEvC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import {nameOf} from \"@tsed/core\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {JsonParameterStore} from \"@tsed/schema\";\nimport {ValidationError} from \"./ValidationError\";\n\nexport class ParamValidationError extends BadRequest {\n public name: string = \"PARAM_VALIDATION_ERROR\";\n public dataPath: string;\n public requestType: string;\n\n static from(metadata: JsonParameterStore, origin: any = {}) {\n if (origin instanceof ValidationError || origin instanceof BadRequest) {\n const name = nameOf(metadata.paramType)\n .toLowerCase()\n .replace(/parse|params|filter/gi, \"\");\n const expression = metadata.expression;\n const message = `Bad request on parameter \"request.${name}${expression ? \".\" + expression : \"\"}\".\\n${origin.message}`.trim();\n\n const error = new ParamValidationError(message);\n error.dataPath = String(metadata.expression) || \"\";\n error.requestType = nameOf(metadata.paramType);\n error.origin = origin.origin || origin;\n\n return error;\n }\n\n return origin;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { nameOf } from "@tsed/core";
2
- import { ValidationError } from "./ValidationError";
2
+ import { ValidationError } from "./ValidationError.js";
3
3
  export class RequiredValidationError extends ValidationError {
4
4
  constructor() {
5
5
  super(...arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"RequiredValidationError.js","sourceRoot":"","sources":["../../../src/errors/RequiredValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAElC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,OAAO,uBAAwB,SAAQ,eAAe;IAA5D;;QACS,SAAI,GAAW,2BAA2B,CAAC;IAuBpD,CAAC;IArBC,MAAM,CAAC,IAAI,CAAC,QAAuB;QACjC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,sCAAsC,UAAU,GAAG,CAAC;QAEpE,MAAM,MAAM,GAAG;YACb;gBACE,QAAQ,EAAE,EAAE;gBACZ,OAAO,EAAE,UAAU;gBACnB,OAAO;gBACP,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE;oBACN,eAAe,EAAE,UAAU;iBAC5B;gBACD,UAAU,EAAE,YAAY;aACzB;SACF,CAAC;QAEF,OAAO,IAAI,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import {nameOf} from \"@tsed/core\";\nimport {ParamMetadata} from \"../domain/ParamMetadata\";\nimport {ValidationError} from \"./ValidationError\";\n\nexport class RequiredValidationError extends ValidationError {\n public name: string = \"REQUIRED_VALIDATION_ERROR\";\n\n static from(metadata: ParamMetadata) {\n const name = nameOf(metadata.paramType);\n const expression = metadata.expression;\n const type = name.toLowerCase().replace(/parse|params|filter/gi, \"\");\n const message = `It should have required parameter '${expression}'`;\n\n const errors = [\n {\n dataPath: \"\",\n keyword: \"required\",\n message,\n modelName: type,\n params: {\n missingProperty: expression\n },\n schemaPath: \"#/required\"\n }\n ];\n\n return new RequiredValidationError(message, errors);\n }\n}\n"]}
1
+ {"version":3,"file":"RequiredValidationError.js","sourceRoot":"","sources":["../../../src/errors/RequiredValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,OAAO,uBAAwB,SAAQ,eAAe;IAA5D;;QACS,SAAI,GAAW,2BAA2B,CAAC;IAuBpD,CAAC;IArBC,MAAM,CAAC,IAAI,CAAC,QAA4B;QACtC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,sCAAsC,UAAU,GAAG,CAAC;QAEpE,MAAM,MAAM,GAAG;YACb;gBACE,QAAQ,EAAE,EAAE;gBACZ,OAAO,EAAE,UAAU;gBACnB,OAAO;gBACP,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE;oBACN,eAAe,EAAE,UAAU;iBAC5B;gBACD,UAAU,EAAE,YAAY;aACzB;SACF,CAAC;QAEF,OAAO,IAAI,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import {nameOf} from \"@tsed/core\";\nimport {ValidationError} from \"./ValidationError\";\nimport {JsonParameterStore} from \"@tsed/schema\";\n\nexport class RequiredValidationError extends ValidationError {\n public name: string = \"REQUIRED_VALIDATION_ERROR\";\n\n static from(metadata: JsonParameterStore) {\n const name = nameOf(metadata.paramType);\n const expression = metadata.expression;\n const type = name.toLowerCase().replace(/parse|params|filter/gi, \"\");\n const message = `It should have required parameter '${expression}'`;\n\n const errors = [\n {\n dataPath: \"\",\n keyword: \"required\",\n message,\n modelName: type,\n params: {\n missingProperty: expression\n },\n schemaPath: \"#/required\"\n }\n ];\n\n return new RequiredValidationError(message, errors);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"","sourcesContent":["export {PipeMethods} from \"@tsed/schema\";\n"]}
package/lib/esm/index.js CHANGED
@@ -1,34 +1,32 @@
1
- export * from "./utils/mapParamsOptions";
2
- // domain
3
- export * from "./domain/ParamMetadata";
4
- export * from "./domain/ParamOptions";
5
- export * from "./domain/ParamTypes";
6
- // pipes
7
- export * from "./pipes/ParseExpressionPipe";
8
- export * from "./pipes/DeserializerPipe";
9
- export * from "./pipes/ValidationPipe";
10
- // builder
11
- export * from "./builder/PlatformParams";
12
- // errors
13
- export * from "./errors/RequiredValidationError";
14
- export * from "./errors/ValidationError";
15
- export * from "./errors/ParamValidationError";
16
- // decorators
17
- export * from "./decorators/context";
18
- export * from "./decorators/bodyParams";
19
- export * from "./decorators/usePipe";
20
- export * from "./decorators/useParam";
21
- export * from "./decorators/useParamType";
22
- export * from "./decorators/useType";
23
- export * from "./decorators/useValidation";
24
- export * from "./decorators/useDeserialization";
25
- export * from "./decorators/useParamExpression";
26
- export * from "./decorators/useParamType";
27
- export * from "./decorators/headerParams";
28
- export * from "./decorators/cookies";
29
- export * from "./decorators/locals";
30
- export * from "./decorators/pathParams";
31
- export * from "./decorators/queryParams";
32
- export * from "./decorators/session";
33
- export * from "./decorators/paramFn";
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./exports.js";
5
+ export * from "./builder/PlatformParams.js";
6
+ export * from "./decorators/bodyParams.js";
7
+ export * from "./decorators/context.js";
8
+ export * from "./decorators/cookies.js";
9
+ export * from "./decorators/headerParams.js";
10
+ export * from "./decorators/locals.js";
11
+ export * from "./decorators/paramFn.js";
12
+ export * from "./decorators/pathParams.js";
13
+ export * from "./decorators/queryParams.js";
14
+ export * from "./decorators/session.js";
15
+ export * from "./decorators/useDeserialization.js";
16
+ export * from "./decorators/useParam.js";
17
+ export * from "./decorators/useParamExpression.js";
18
+ export * from "./decorators/useParamType.js";
19
+ export * from "./decorators/usePipe.js";
20
+ export * from "./decorators/useType.js";
21
+ export * from "./decorators/useValidation.js";
22
+ export * from "./domain/ParamMetadata.js";
23
+ export * from "./domain/ParamOptions.js";
24
+ export * from "./domain/ParamTypes.js";
25
+ export * from "./errors/ParamValidationError.js";
26
+ export * from "./errors/RequiredValidationError.js";
27
+ export * from "./errors/ValidationError.js";
28
+ export * from "./pipes/DeserializerPipe.js";
29
+ export * from "./pipes/ParseExpressionPipe.js";
30
+ export * from "./pipes/ValidationPipe.js";
31
+ export * from "./utils/mapParamsOptions.js";
34
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AAEzC,SAAS;AACT,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AAEpC,QAAQ;AACR,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AAEvC,UAAU;AACV,cAAc,0BAA0B,CAAC;AAEzC,SAAS;AACT,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAE9C,aAAa;AACb,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./utils/mapParamsOptions\";\n\n// domain\nexport * from \"./domain/ParamMetadata\";\nexport * from \"./domain/ParamOptions\";\nexport * from \"./domain/ParamTypes\";\n\n// pipes\nexport * from \"./pipes/ParseExpressionPipe\";\nexport * from \"./pipes/DeserializerPipe\";\nexport * from \"./pipes/ValidationPipe\";\n\n// builder\nexport * from \"./builder/PlatformParams\";\n\n// errors\nexport * from \"./errors/RequiredValidationError\";\nexport * from \"./errors/ValidationError\";\nexport * from \"./errors/ParamValidationError\";\n\n// decorators\nexport * from \"./decorators/context\";\nexport * from \"./decorators/bodyParams\";\nexport * from \"./decorators/usePipe\";\nexport * from \"./decorators/useParam\";\nexport * from \"./decorators/useParamType\";\nexport * from \"./decorators/useType\";\nexport * from \"./decorators/useValidation\";\nexport * from \"./decorators/useDeserialization\";\nexport * from \"./decorators/useParamExpression\";\nexport * from \"./decorators/useParamType\";\nexport * from \"./decorators/headerParams\";\nexport * from \"./decorators/cookies\";\nexport * from \"./decorators/locals\";\nexport * from \"./decorators/pathParams\";\nexport * from \"./decorators/queryParams\";\nexport * from \"./decorators/session\";\nexport * from \"./decorators/paramFn\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformParams\";\nexport * from \"./decorators/bodyParams\";\nexport * from \"./decorators/context\";\nexport * from \"./decorators/cookies\";\nexport * from \"./decorators/headerParams\";\nexport * from \"./decorators/locals\";\nexport * from \"./decorators/paramFn\";\nexport * from \"./decorators/pathParams\";\nexport * from \"./decorators/queryParams\";\nexport * from \"./decorators/session\";\nexport * from \"./decorators/useDeserialization\";\nexport * from \"./decorators/useParam\";\nexport * from \"./decorators/useParamExpression\";\nexport * from \"./decorators/useParamType\";\nexport * from \"./decorators/usePipe\";\nexport * from \"./decorators/useType\";\nexport * from \"./decorators/useValidation\";\nexport * from \"./domain/ParamMetadata\";\nexport * from \"./domain/ParamOptions\";\nexport * from \"./domain/ParamTypes\";\nexport * from \"./errors/ParamValidationError\";\nexport * from \"./errors/RequiredValidationError\";\nexport * from \"./errors/ValidationError\";\nexport * from \"./pipes/DeserializerPipe\";\nexport * from \"./pipes/ParseExpressionPipe\";\nexport * from \"./pipes/ValidationPipe\";\nexport * from \"./utils/mapParamsOptions\";\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"DeserializerPipe.js","sourceRoot":"","sources":["../../../src/pipes/DeserializerPipe.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAI9C,IAAa,gBAAgB,wBAA7B,MAAa,gBAAgB;IAM3B,SAAS,CAAC,KAAU,EAAE,KAAoB;QACxC,OAAO,WAAW,CAAC,KAAK,EAAE;YACxB,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,oBAAoB,KAAK,QAAQ;YACrE,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;YAC9B,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;YACrC,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAgB,CAAC,IAAI,EAAE,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhBC;IADC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;;kDAGxB;AAJS,gBAAgB;IAD5B,UAAU,EAAE;GACA,gBAAgB,CAkB5B;SAlBY,gBAAgB","sourcesContent":["import {Constant, Injectable} from \"@tsed/di\";\nimport {deserialize} from \"@tsed/json-mapper\";\nimport {ParamMetadata, PipeMethods} from \"../domain/ParamMetadata\";\n\n@Injectable()\nexport class DeserializerPipe implements PipeMethods {\n @Constant(\"converter\", {})\n private settings: {\n additionalProperties?: \"error\" | \"accept\" | \"ignore\";\n };\n\n transform(value: any, param: ParamMetadata) {\n return deserialize(value, {\n useAlias: true,\n additionalProperties: this.settings.additionalProperties === \"accept\",\n type: param.type,\n collectionType: param.collectionType,\n groups: param.parameter.groups,\n genericTypes: param.nestedGenerics[0],\n nestedGenerics: param.nestedGenerics,\n ...(param.store.get(DeserializerPipe) || {})\n });\n }\n}\n"]}
1
+ {"version":3,"file":"DeserializerPipe.js","sourceRoot":"","sources":["../../../src/pipes/DeserializerPipe.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAI9C,IAAa,gBAAgB,wBAA7B,MAAa,gBAAgB;IAM3B,SAAS,CAAC,KAAU,EAAE,KAAyB;QAC7C,OAAO,WAAW,CAAC,KAAK,EAAE;YACxB,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,oBAAoB,KAAK,QAAQ;YACrE,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;YAC9B,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;YACrC,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAgB,CAAC,IAAI,EAAE,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhBC;IADC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;;kDAGxB;AAJS,gBAAgB;IAD5B,UAAU,EAAE;GACA,gBAAgB,CAkB5B;SAlBY,gBAAgB","sourcesContent":["import {Constant, Injectable} from \"@tsed/di\";\nimport {deserialize} from \"@tsed/json-mapper\";\nimport {JsonParameterStore, PipeMethods} from \"@tsed/schema\";\n\n@Injectable()\nexport class DeserializerPipe implements PipeMethods {\n @Constant(\"converter\", {})\n private settings: {\n additionalProperties?: \"error\" | \"accept\" | \"ignore\";\n };\n\n transform(value: any, param: JsonParameterStore) {\n return deserialize(value, {\n useAlias: true,\n additionalProperties: this.settings.additionalProperties === \"accept\",\n type: param.type,\n collectionType: param.collectionType,\n groups: param.parameter.groups,\n genericTypes: param.nestedGenerics[0],\n nestedGenerics: param.nestedGenerics,\n ...(param.store.get(DeserializerPipe) || {})\n });\n }\n}\n"]}
@@ -1,16 +1,24 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { getValue } from "@tsed/core";
3
3
  import { Injectable } from "@tsed/di";
4
- import { ParamTypes } from "../domain/ParamTypes";
4
+ import { ParamTypes } from "../domain/ParamTypes.js";
5
5
  let ParseExpressionPipe = class ParseExpressionPipe {
6
6
  transform(scope, param) {
7
7
  const { paramType, type } = param;
8
- const value = getValue(scope, param.key);
8
+ const value = getValue(scope, this.getKey(param));
9
9
  if ([ParamTypes.QUERY, ParamTypes.PATH].includes(paramType) && value === "" && type !== String) {
10
10
  return undefined;
11
11
  }
12
12
  return value;
13
13
  }
14
+ getKey(param) {
15
+ let { expression, paramType, dataPath } = param;
16
+ paramType = paramType || param.parameter.get("in").toUpperCase();
17
+ if (expression && paramType === ParamTypes.HEADER) {
18
+ expression = String(expression).toLowerCase();
19
+ }
20
+ return [dataPath, expression].filter(Boolean).join(".");
21
+ }
14
22
  };
15
23
  ParseExpressionPipe = __decorate([
16
24
  Injectable({
@@ -1 +1 @@
1
- {"version":3,"file":"ParseExpressionPipe.js","sourceRoot":"","sources":["../../../src/pipes/ParseExpressionPipe.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAMhD,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAC9B,SAAS,CAAC,KAAe,EAAE,KAAoB;QAC7C,MAAM,EAAC,SAAS,EAAE,IAAI,EAAC,GAAG,KAAK,CAAC;QAEhC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAEzC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAuB,CAAC,IAAI,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,MAAM,EAAE;YAC5G,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAZY,mBAAmB;IAH/B,UAAU,CAAC;QACV,QAAQ,EAAE,CAAC,IAAI;KAChB,CAAC;GACW,mBAAmB,CAY/B;SAZY,mBAAmB","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {Injectable} from \"@tsed/di\";\nimport {PipeMethods, ParamMetadata} from \"../domain/ParamMetadata\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport type {ArgScope} from \"../builder/PlatformParams\";\n\n@Injectable({\n priority: -1000\n})\nexport class ParseExpressionPipe implements PipeMethods {\n transform(scope: ArgScope, param: ParamMetadata) {\n const {paramType, type} = param;\n\n const value = getValue(scope, param.key);\n\n if ([ParamTypes.QUERY, ParamTypes.PATH].includes(paramType as ParamTypes) && value === \"\" && type !== String) {\n return undefined;\n }\n\n return value;\n }\n}\n"]}
1
+ {"version":3,"file":"ParseExpressionPipe.js","sourceRoot":"","sources":["../../../src/pipes/ParseExpressionPipe.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAMhD,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAC9B,SAAS,CAAC,KAAe,EAAE,KAAyB;QAClD,MAAM,EAAC,SAAS,EAAE,IAAI,EAAC,GAAG,KAAK,CAAC;QAEhC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAuB,CAAC,IAAI,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,MAAM,EAAE;YAC5G,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAES,MAAM,CAAC,KAAyB;QACxC,IAAI,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAC;QAC9C,SAAS,GAAG,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAEjE,IAAI,UAAU,IAAI,SAAS,KAAK,UAAU,CAAC,MAAM,EAAE;YACjD,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;SAC/C;QAED,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AAvBY,mBAAmB;IAH/B,UAAU,CAAC;QACV,QAAQ,EAAE,CAAC,IAAI;KAChB,CAAC;GACW,mBAAmB,CAuB/B;SAvBY,mBAAmB","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {Injectable} from \"@tsed/di\";\nimport {JsonParameterStore, PipeMethods} from \"@tsed/schema\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\nimport type {ArgScope} from \"../builder/PlatformParams\";\n\n@Injectable({\n priority: -1000\n})\nexport class ParseExpressionPipe implements PipeMethods {\n transform(scope: ArgScope, param: JsonParameterStore) {\n const {paramType, type} = param;\n\n const value = getValue(scope, this.getKey(param));\n\n if ([ParamTypes.QUERY, ParamTypes.PATH].includes(paramType as ParamTypes) && value === \"\" && type !== String) {\n return undefined;\n }\n\n return value;\n }\n\n protected getKey(param: JsonParameterStore) {\n let {expression, paramType, dataPath} = param;\n paramType = paramType || param.parameter.get(\"in\").toUpperCase();\n\n if (expression && paramType === ParamTypes.HEADER) {\n expression = String(expression).toLowerCase();\n }\n\n return [dataPath, expression].filter(Boolean).join(\".\");\n }\n}\n"]}
@@ -3,8 +3,8 @@ import { nameOf } from "@tsed/core";
3
3
  import { Injectable, InjectorService } from "@tsed/di";
4
4
  import { deserialize } from "@tsed/json-mapper";
5
5
  import { getJsonSchema } from "@tsed/schema";
6
- import { RequiredValidationError } from "../errors/RequiredValidationError";
7
- import { ParamTypes } from "../domain/ParamTypes";
6
+ import { RequiredValidationError } from "../errors/RequiredValidationError.js";
7
+ import { ParamTypes } from "../domain/ParamTypes.js";
8
8
  function cast(value, metadata) {
9
9
  try {
10
10
  return deserialize(value, {
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.ts"],"names":[],"mappings":"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","sourcesContent":["import {nameOf} from \"@tsed/core\";\nimport {Injectable, InjectorService} from \"@tsed/di\";\nimport {deserialize} from \"@tsed/json-mapper\";\nimport {getJsonSchema} from \"@tsed/schema\";\nimport {RequiredValidationError} from \"../errors/RequiredValidationError\";\nimport {ParamMetadata, PipeMethods} from \"../domain/ParamMetadata\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\n\nfunction cast(value: any, metadata: ParamMetadata) {\n try {\n return deserialize(value, {\n type: metadata.type\n });\n } catch (er) {\n return value;\n }\n}\n\n@Injectable({\n type: \"validator\"\n})\nexport class ValidationPipe implements PipeMethods {\n private validator: {validate(value: any, options: any): Promise<any>};\n\n constructor(injector: InjectorService) {\n const provider = injector.getProviders().find((provider) => nameOf(provider.token) === \"AjvService\");\n\n if (provider) {\n this.validator = injector.invoke<any>(provider.token);\n }\n }\n\n coerceTypes(value: any, metadata: ParamMetadata) {\n if (value === undefined) {\n return value;\n }\n\n if (value === \"null\") {\n return null;\n }\n\n if (metadata.isArray) {\n return [].concat(value);\n }\n\n if (metadata.isPrimitive) {\n return cast(value, metadata);\n }\n\n return value;\n }\n\n skip(value: any, metadata: ParamMetadata) {\n return metadata.paramType === ParamTypes.PATH && !metadata.isPrimitive;\n }\n\n async transform(value: any, metadata: ParamMetadata): Promise<any> {\n if (!this.validator) {\n this.checkIsRequired(value, metadata);\n return value;\n }\n\n if (this.skip(value, metadata)) {\n return value;\n }\n\n value = this.coerceTypes(value, metadata);\n\n this.checkIsRequired(value, metadata);\n\n if (value === undefined) {\n return value;\n }\n\n const schema = getJsonSchema(metadata, {\n customKeys: true\n });\n\n await this.validator.validate(value, {\n schema,\n type: metadata.isClass ? metadata.type : undefined,\n collectionType: metadata.collectionType\n });\n\n return value;\n }\n\n protected checkIsRequired(value: any, metadata: ParamMetadata) {\n if (metadata.isRequired(value)) {\n throw RequiredValidationError.from(metadata);\n }\n\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.ts"],"names":[],"mappings":"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","sourcesContent":["import {nameOf} from \"@tsed/core\";\nimport {Injectable, InjectorService} from \"@tsed/di\";\nimport {deserialize} from \"@tsed/json-mapper\";\nimport {getJsonSchema, JsonParameterStore, PipeMethods} from \"@tsed/schema\";\nimport {RequiredValidationError} from \"../errors/RequiredValidationError\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\n\nfunction cast(value: any, metadata: JsonParameterStore) {\n try {\n return deserialize(value, {\n type: metadata.type\n });\n } catch (er) {\n return value;\n }\n}\n\n@Injectable({\n type: \"validator\"\n})\nexport class ValidationPipe implements PipeMethods {\n private validator: {validate(value: any, options: any): Promise<any>};\n\n constructor(injector: InjectorService) {\n const provider = injector.getProviders().find((provider) => nameOf(provider.token) === \"AjvService\");\n\n if (provider) {\n this.validator = injector.invoke<any>(provider.token);\n }\n }\n\n coerceTypes(value: any, metadata: JsonParameterStore) {\n if (value === undefined) {\n return value;\n }\n\n if (value === \"null\") {\n return null;\n }\n\n if (metadata.isArray) {\n return [].concat(value);\n }\n\n if (metadata.isPrimitive) {\n return cast(value, metadata);\n }\n\n return value;\n }\n\n skip(value: any, metadata: JsonParameterStore) {\n return metadata.paramType === ParamTypes.PATH && !metadata.isPrimitive;\n }\n\n async transform(value: any, metadata: JsonParameterStore): Promise<any> {\n if (!this.validator) {\n this.checkIsRequired(value, metadata);\n return value;\n }\n\n if (this.skip(value, metadata)) {\n return value;\n }\n\n value = this.coerceTypes(value, metadata);\n\n this.checkIsRequired(value, metadata);\n\n if (value === undefined) {\n return value;\n }\n\n const schema = getJsonSchema(metadata, {\n customKeys: true\n });\n\n await this.validator.validate(value, {\n schema,\n type: metadata.isClass ? metadata.type : undefined,\n collectionType: metadata.collectionType\n });\n\n return value;\n }\n\n protected checkIsRequired(value: any, metadata: JsonParameterStore) {\n if (metadata.isRequired(value)) {\n throw RequiredValidationError.from(metadata);\n }\n\n return true;\n }\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import { DIContext, InjectorService, TokenProvider } from "@tsed/di";
2
- import { JsonEntityStore } from "@tsed/schema";
3
- import { ParamMetadata, PipeMethods } from "../domain/ParamMetadata";
2
+ import { JsonEntityStore, JsonParameterStore, PipeMethods } from "@tsed/schema";
4
3
  export declare type ArgScope<Context extends DIContext = DIContext> = {
5
4
  $ctx: Context;
6
5
  } & Record<string, any>;
@@ -16,8 +15,8 @@ export interface CompileHandlerOptions<Context extends DIContext = DIContext> ex
16
15
  */
17
16
  export declare class PlatformParams {
18
17
  protected injector: InjectorService;
19
- getPipes(param: ParamMetadata): Promise<PipeMethods<any, any>[]>;
18
+ getPipes(param: JsonParameterStore): Promise<PipeMethods<any, any>[]>;
20
19
  compile<Context extends DIContext = DIContext>(entity: JsonEntityStore): Promise<(scope: ArgScope<Context>) => Promise<any[]>>;
21
- getArg(scope: ArgScope, pipes: PipeMethods[], param: ParamMetadata): Promise<any>;
20
+ getArg(scope: ArgScope, pipes: PipeMethods[], param: JsonParameterStore): Promise<any>;
22
21
  compileHandler<Context extends DIContext = DIContext>(metadata: CompileHandlerOptions<Context>): Promise<HandlerWithScope<Context>>;
23
22
  }
@@ -60,5 +60,6 @@ export declare function BodyParams(): ParameterDecorator;
60
60
  * @decorator
61
61
  * @operation
62
62
  * @input
63
+ * @alias BodyParams Example: @BodyParams() payload: Buffer
63
64
  */
64
65
  export declare function RawBodyParams(): ParameterDecorator;
@@ -1,10 +1,4 @@
1
1
  import { BaseContext } from "@tsed/di";
2
- declare global {
3
- namespace TsED {
4
- interface Context {
5
- }
6
- }
7
- }
8
2
  /**
9
3
  * Context decorator return the @@PlatformContext@@ created by Ts.ED when request is handled by the server.
10
4
  *
@@ -1,5 +1,5 @@
1
1
  import { DecoratorParameters } from "@tsed/core";
2
- import { ParamMetadata } from "../domain/ParamMetadata";
2
+ import { JsonParameterStore } from "@tsed/schema";
3
3
  /**
4
4
  * Get the Param metadata. Use this decorator to compose your own decorator.
5
5
  *
@@ -8,4 +8,4 @@ import { ParamMetadata } from "../domain/ParamMetadata";
8
8
  * @operation
9
9
  * @input
10
10
  */
11
- export declare function ParamFn(fn: (param: ParamMetadata, parameters: DecoratorParameters) => void): ParameterDecorator;
11
+ export declare function ParamFn(fn: (param: JsonParameterStore, parameters: DecoratorParameters) => void): ParameterDecorator;
@@ -1,5 +1,5 @@
1
1
  import { Type } from "@tsed/core";
2
- import { PipeMethods } from "../domain/ParamMetadata";
2
+ import { PipeMethods } from "@tsed/schema";
3
3
  /**
4
4
  * Register a Pipe to be used with the current decorated param.
5
5
  *
@@ -1,16 +1 @@
1
- import { Type } from "@tsed/core";
2
- import { JsonEntityStoreOptions, JsonParameterStore } from "@tsed/schema";
3
- import { ParamOptions } from "./ParamOptions";
4
- export interface PipeMethods<T = any, R = any> {
5
- transform(value: T, metadata: ParamMetadata): R;
6
- }
7
- export declare type ParamConstructorOptions = JsonEntityStoreOptions & ParamOptions;
8
- export declare class ParamMetadata extends JsonParameterStore implements ParamConstructorOptions {
9
- expression: string;
10
- dataPath: string;
11
- paramType: string;
12
- pipes: Type<PipeMethods>[];
13
- constructor(options: ParamConstructorOptions);
14
- get key(): string;
15
- static get(target: Type<any>, propertyKey: string | symbol, index: number): ParamMetadata;
16
- }
1
+ export { ParamMetadata } from "@tsed/schema";
@@ -22,3 +22,4 @@ export declare enum ParamTypes {
22
22
  RES = "RES",
23
23
  REQ = "REQ"
24
24
  }
25
+ export declare const PARAM_TYPES_DATA_PATH: Record<string, string>;
@@ -1,8 +1,8 @@
1
1
  import { BadRequest } from "@tsed/exceptions";
2
- import { ParamMetadata } from "../domain/ParamMetadata";
2
+ import { JsonParameterStore } from "@tsed/schema";
3
3
  export declare class ParamValidationError extends BadRequest {
4
4
  name: string;
5
5
  dataPath: string;
6
6
  requestType: string;
7
- static from(metadata: ParamMetadata, origin?: any): any;
7
+ static from(metadata: JsonParameterStore, origin?: any): any;
8
8
  }
@@ -1,6 +1,6 @@
1
- import { ParamMetadata } from "../domain/ParamMetadata";
2
1
  import { ValidationError } from "./ValidationError";
2
+ import { JsonParameterStore } from "@tsed/schema";
3
3
  export declare class RequiredValidationError extends ValidationError {
4
4
  name: string;
5
- static from(metadata: ParamMetadata): RequiredValidationError;
5
+ static from(metadata: JsonParameterStore): RequiredValidationError;
6
6
  }
@@ -0,0 +1 @@
1
+ export { PipeMethods } from "@tsed/schema";