@tsed/platform-params 8.0.0-alpha.5 → 8.0.0-alpha.7
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/esm/builder/PlatformParams.js.map +1 -1
- package/lib/esm/decorators/bodyParams.js +1 -1
- package/lib/esm/decorators/bodyParams.js.map +1 -1
- package/lib/esm/decorators/context.js.map +1 -1
- package/lib/esm/decorators/cookies.js.map +1 -1
- package/lib/esm/decorators/headerParams.js +1 -1
- package/lib/esm/decorators/headerParams.js.map +1 -1
- package/lib/esm/decorators/pathParams.js.map +1 -1
- package/lib/esm/decorators/queryParams.js.map +1 -1
- package/lib/esm/decorators/useParam.js.map +1 -1
- package/lib/esm/decorators/useParamType.js +1 -1
- package/lib/esm/decorators/useParamType.js.map +1 -1
- package/lib/esm/decorators/usePipe.js.map +1 -1
- package/lib/esm/decorators/useType.js.map +1 -1
- package/lib/esm/decorators/useValidation.js.map +1 -1
- package/lib/esm/errors/ParamValidationError.js.map +1 -1
- package/lib/esm/errors/RequiredValidationError.js.map +1 -1
- package/lib/esm/pipes/DeserializerPipe.js.map +1 -1
- package/lib/esm/pipes/ParseExpressionPipe.js.map +1 -1
- package/lib/esm/pipes/ValidationPipe.js.map +1 -1
- package/lib/esm/utils/mapParamsOptions.js.map +1 -1
- package/lib/types/errors/RequiredValidationError.d.ts +1 -1
- package/package.json +18 -19
- package/vitest.config.mts +4 -4
- package/lib/cjs/builder/PlatformParams.js +0 -75
- package/lib/cjs/builder/PlatformParams.js.map +0 -1
- package/lib/cjs/decorators/bodyParams.js +0 -28
- package/lib/cjs/decorators/bodyParams.js.map +0 -1
- package/lib/cjs/decorators/context.js +0 -18
- package/lib/cjs/decorators/context.js.map +0 -1
- package/lib/cjs/decorators/cookies.js +0 -23
- package/lib/cjs/decorators/cookies.js.map +0 -1
- package/lib/cjs/decorators/headerParams.js +0 -18
- package/lib/cjs/decorators/headerParams.js.map +0 -1
- package/lib/cjs/decorators/locals.js +0 -18
- package/lib/cjs/decorators/locals.js.map +0 -1
- package/lib/cjs/decorators/paramFn.js +0 -17
- package/lib/cjs/decorators/paramFn.js.map +0 -1
- package/lib/cjs/decorators/pathParams.js +0 -28
- package/lib/cjs/decorators/pathParams.js.map +0 -1
- package/lib/cjs/decorators/queryParams.js +0 -28
- package/lib/cjs/decorators/queryParams.js.map +0 -1
- package/lib/cjs/decorators/session.js +0 -18
- package/lib/cjs/decorators/session.js.map +0 -1
- package/lib/cjs/decorators/useDeserialization.js +0 -18
- package/lib/cjs/decorators/useDeserialization.js.map +0 -1
- package/lib/cjs/decorators/useParam.js +0 -38
- package/lib/cjs/decorators/useParam.js.map +0 -1
- package/lib/cjs/decorators/useParamExpression.js +0 -20
- package/lib/cjs/decorators/useParamExpression.js.map +0 -1
- package/lib/cjs/decorators/useParamType.js +0 -31
- package/lib/cjs/decorators/useParamType.js.map +0 -1
- package/lib/cjs/decorators/usePipe.js +0 -22
- package/lib/cjs/decorators/usePipe.js.map +0 -1
- package/lib/cjs/decorators/useType.js +0 -34
- package/lib/cjs/decorators/useType.js.map +0 -1
- package/lib/cjs/decorators/useValidation.js +0 -22
- package/lib/cjs/decorators/useValidation.js.map +0 -1
- package/lib/cjs/domain/ParamMetadata.js +0 -6
- package/lib/cjs/domain/ParamMetadata.js.map +0 -1
- package/lib/cjs/domain/ParamOptions.js +0 -3
- package/lib/cjs/domain/ParamOptions.js.map +0 -1
- package/lib/cjs/domain/ParamTypes.js +0 -40
- package/lib/cjs/domain/ParamTypes.js.map +0 -1
- package/lib/cjs/errors/ParamValidationError.js +0 -36
- package/lib/cjs/errors/ParamValidationError.js.map +0 -1
- package/lib/cjs/errors/RequiredValidationError.js +0 -32
- package/lib/cjs/errors/RequiredValidationError.js.map +0 -1
- package/lib/cjs/errors/ValidationError.js +0 -13
- package/lib/cjs/errors/ValidationError.js.map +0 -1
- package/lib/cjs/exports.js +0 -3
- package/lib/cjs/exports.js.map +0 -1
- package/lib/cjs/index.js +0 -35
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/pipes/DeserializerPipe.js +0 -21
- package/lib/cjs/pipes/DeserializerPipe.js.map +0 -1
- package/lib/cjs/pipes/ParseExpressionPipe.js +0 -32
- package/lib/cjs/pipes/ParseExpressionPipe.js.map +0 -1
- package/lib/cjs/pipes/ValidationPipe.js +0 -80
- package/lib/cjs/pipes/ValidationPipe.js.map +0 -1
- package/lib/cjs/utils/mapParamsOptions.js +0 -32
- package/lib/cjs/utils/mapParamsOptions.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/builder/PlatformParams.d.ts +0 -25
- package/lib/types-esm/decorators/bodyParams.d.ts +0 -66
- package/lib/types-esm/decorators/context.d.ts +0 -53
- package/lib/types-esm/decorators/cookies.d.ts +0 -81
- package/lib/types-esm/decorators/headerParams.d.ts +0 -33
- package/lib/types-esm/decorators/locals.d.ts +0 -42
- package/lib/types-esm/decorators/paramFn.d.ts +0 -11
- package/lib/types-esm/decorators/pathParams.d.ts +0 -70
- package/lib/types-esm/decorators/queryParams.d.ts +0 -75
- package/lib/types-esm/decorators/session.d.ts +0 -36
- package/lib/types-esm/decorators/useDeserialization.d.ts +0 -9
- package/lib/types-esm/decorators/useParam.d.ts +0 -18
- package/lib/types-esm/decorators/useParamExpression.d.ts +0 -10
- package/lib/types-esm/decorators/useParamType.d.ts +0 -10
- package/lib/types-esm/decorators/usePipe.d.ts +0 -13
- package/lib/types-esm/decorators/useType.d.ts +0 -13
- package/lib/types-esm/decorators/useValidation.d.ts +0 -9
- package/lib/types-esm/domain/ParamMetadata.d.ts +0 -1
- package/lib/types-esm/domain/ParamOptions.d.ts +0 -10
- package/lib/types-esm/domain/ParamTypes.d.ts +0 -25
- package/lib/types-esm/errors/ParamValidationError.d.ts +0 -8
- package/lib/types-esm/errors/RequiredValidationError.d.ts +0 -6
- package/lib/types-esm/errors/ValidationError.d.ts +0 -6
- package/lib/types-esm/exports.d.ts +0 -1
- package/lib/types-esm/index.d.ts +0 -31
- package/lib/types-esm/pipes/DeserializerPipe.d.ts +0 -4
- package/lib/types-esm/pipes/ParseExpressionPipe.d.ts +0 -6
- package/lib/types-esm/pipes/ValidationPipe.d.ts +0 -12
- package/lib/types-esm/utils/mapParamsOptions.d.ts +0 -5
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UseDeserialization = void 0;
|
|
4
|
-
const DeserializerPipe_js_1 = require("../pipes/DeserializerPipe.js");
|
|
5
|
-
const usePipe_js_1 = require("./usePipe.js");
|
|
6
|
-
/**
|
|
7
|
-
* Use JsonMapper to deserialize the data.
|
|
8
|
-
*
|
|
9
|
-
* @decorator
|
|
10
|
-
* @operation
|
|
11
|
-
* @input
|
|
12
|
-
* @pipe
|
|
13
|
-
*/
|
|
14
|
-
function UseDeserialization(options = {}) {
|
|
15
|
-
return (0, usePipe_js_1.UsePipe)(DeserializerPipe_js_1.DeserializerPipe, options);
|
|
16
|
-
}
|
|
17
|
-
exports.UseDeserialization = UseDeserialization;
|
|
18
|
-
//# sourceMappingURL=useDeserialization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDeserialization.js","sourceRoot":"","sources":["../../../src/decorators/useDeserialization.ts"],"names":[],"mappings":";;;AAAA,sEAA8D;AAC9D,6CAAqC;AAErC;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,UAAe,EAAE;IAClD,OAAO,IAAA,oBAAO,EAAC,sCAAgB,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAFD,gDAEC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UseParam = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const ParamTypes_js_1 = require("../domain/ParamTypes.js");
|
|
6
|
-
const useDeserialization_js_1 = require("./useDeserialization.js");
|
|
7
|
-
const useParamType_js_1 = require("./useParamType.js");
|
|
8
|
-
const useType_js_1 = require("./useType.js");
|
|
9
|
-
const useValidation_js_1 = require("./useValidation.js");
|
|
10
|
-
/**
|
|
11
|
-
* @ignore
|
|
12
|
-
* @param options
|
|
13
|
-
*/
|
|
14
|
-
function mapPipes(options) {
|
|
15
|
-
const { paramType, useType, expression, useValidation, useMapper, ...props } = options;
|
|
16
|
-
return [paramType !== ParamTypes_js_1.ParamTypes.FILES && (0, useType_js_1.UseType)(useType), useValidation && (0, useValidation_js_1.UseValidation)(), useMapper && (0, useDeserialization_js_1.UseDeserialization)(props)];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Register a new param. It uses the paramType to extract value and give it to the next pipe.
|
|
20
|
-
*
|
|
21
|
-
* Given options allow to enable or disable following pipes:
|
|
22
|
-
*
|
|
23
|
-
* - useType: Add extra type for the json mapper,
|
|
24
|
-
* - expression: Get property from the returned value by the previous pipe.
|
|
25
|
-
* - useValidation: Apply validation from the returned value by the previous pipe.
|
|
26
|
-
* - useMapper: Apply json mapper from the returned value by the previous pipe.
|
|
27
|
-
*
|
|
28
|
-
* @param options
|
|
29
|
-
* @decorator
|
|
30
|
-
* @operation
|
|
31
|
-
* @input
|
|
32
|
-
* @pipe
|
|
33
|
-
*/
|
|
34
|
-
function UseParam(options) {
|
|
35
|
-
return (0, core_1.useDecorators)((0, useParamType_js_1.UseParamType)(options), ...mapPipes(options));
|
|
36
|
-
}
|
|
37
|
-
exports.UseParam = UseParam;
|
|
38
|
-
//# sourceMappingURL=useParam.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useParam.js","sourceRoot":"","sources":["../../../src/decorators/useParam.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AAEzC,2DAAmD;AACnD,mEAA2D;AAC3D,uDAA+C;AAC/C,6CAAqC;AACrC,yDAAiD;AAEjD;;;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,0BAAU,CAAC,KAAK,IAAI,IAAA,oBAAO,EAAC,OAAO,CAAC,EAAE,aAAa,IAAI,IAAA,gCAAa,GAAE,EAAE,SAAS,IAAI,IAAA,0CAAkB,EAAC,KAAK,CAAC,CAAC,CAAC;AACxI,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,QAAQ,CAAC,OAA8B;IACrD,OAAO,IAAA,oBAAa,EAAC,IAAA,8BAAY,EAAC,OAAc,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAuB,CAAC;AACjG,CAAC;AAFD,4BAEC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UseParamExpression = void 0;
|
|
4
|
-
const paramFn_js_1 = require("./paramFn.js");
|
|
5
|
-
/**
|
|
6
|
-
* Get data from a path inside the given object
|
|
7
|
-
*
|
|
8
|
-
* @param expression
|
|
9
|
-
* @decorator
|
|
10
|
-
* @operation
|
|
11
|
-
* @input
|
|
12
|
-
* @pipe
|
|
13
|
-
*/
|
|
14
|
-
function UseParamExpression(expression) {
|
|
15
|
-
return (0, paramFn_js_1.ParamFn)((param) => {
|
|
16
|
-
param.expression = expression || "";
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
exports.UseParamExpression = UseParamExpression;
|
|
20
|
-
//# sourceMappingURL=useParamExpression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useParamExpression.js","sourceRoot":"","sources":["../../../src/decorators/useParamExpression.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AAErC;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,UAAmB;IACpD,OAAO,IAAA,oBAAO,EAAC,CAAC,KAAK,EAAE,EAAE;QACvB,KAAK,CAAC,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,gDAIC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UseParamType = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const schema_1 = require("@tsed/schema");
|
|
6
|
-
const paramFn_js_1 = require("./paramFn.js");
|
|
7
|
-
const useParamExpression_js_1 = require("./useParamExpression.js");
|
|
8
|
-
const ParamTypes_js_1 = require("../domain/ParamTypes.js");
|
|
9
|
-
/**
|
|
10
|
-
* Get the object from request (like body, params, query, etc...).
|
|
11
|
-
*
|
|
12
|
-
* @decorator
|
|
13
|
-
* @operation
|
|
14
|
-
* @input
|
|
15
|
-
* @pipe
|
|
16
|
-
*/
|
|
17
|
-
function UseParamType(options) {
|
|
18
|
-
return (0, core_1.useDecorators)((0, paramFn_js_1.ParamFn)((param) => {
|
|
19
|
-
if ((0, schema_1.isParameterType)(options.paramType)) {
|
|
20
|
-
param.parameter.in(options.paramType);
|
|
21
|
-
}
|
|
22
|
-
param.paramType = options.paramType;
|
|
23
|
-
if ((0, core_1.isBuffer)(param.type) || (0, core_1.isBuffer)(options.useType) || options.paramType === ParamTypes_js_1.ParamTypes.RAW_BODY) {
|
|
24
|
-
param.paramType = ParamTypes_js_1.ParamTypes.RAW_BODY;
|
|
25
|
-
param.parent.operation?.consumes(["*/*"]);
|
|
26
|
-
}
|
|
27
|
-
param.dataPath = options.dataPath || ParamTypes_js_1.PARAM_TYPES_DATA_PATH[param.paramType] || "$ctx";
|
|
28
|
-
}), options.expression && (0, useParamExpression_js_1.UseParamExpression)(options.expression), options.expression && (0, schema_1.Name)(options.expression));
|
|
29
|
-
}
|
|
30
|
-
exports.UseParamType = UseParamType;
|
|
31
|
-
//# sourceMappingURL=useParamType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useParamType.js","sourceRoot":"","sources":["../../../src/decorators/useParamType.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAmD;AACnD,6CAAqC;AAErC,mEAA2D;AAC3D,2DAA0E;AAE1E;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,OAAqB;IAChD,OAAO,IAAA,oBAAa,EAClB,IAAA,oBAAO,EAAC,CAAC,KAAK,EAAE,EAAE;QAChB,IAAI,IAAA,wBAAe,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACtC,KAAK,CAAC,SAAU,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SACxC;QAED,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAEpC,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,SAAS,KAAK,0BAAU,CAAC,QAAQ,EAAE;YAClG,KAAK,CAAC,SAAS,GAAG,0BAAU,CAAC,QAAQ,CAAC;YACtC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;SAC3C;QAED,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,qCAAqB,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC;IACxF,CAAC,CAAC,EACF,OAAO,CAAC,UAAU,IAAI,IAAA,0CAAkB,EAAC,OAAO,CAAC,UAAU,CAAC,EAC5D,OAAO,CAAC,UAAU,IAAI,IAAA,aAAI,EAAC,OAAO,CAAC,UAAU,CAAC,CAC/C,CAAC;AACJ,CAAC;AAnBD,oCAmBC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UsePipe = void 0;
|
|
4
|
-
const paramFn_js_1 = require("./paramFn.js");
|
|
5
|
-
/**
|
|
6
|
-
* Register a Pipe to be used with the current decorated param.
|
|
7
|
-
*
|
|
8
|
-
* @param token
|
|
9
|
-
* @param options
|
|
10
|
-
* @decorator
|
|
11
|
-
* @operation
|
|
12
|
-
* @input
|
|
13
|
-
* @pipe
|
|
14
|
-
*/
|
|
15
|
-
function UsePipe(token, options = {}) {
|
|
16
|
-
return (0, paramFn_js_1.ParamFn)((param) => {
|
|
17
|
-
param.store.set(token, options);
|
|
18
|
-
param.pipes.push(token);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
exports.UsePipe = UsePipe;
|
|
22
|
-
//# sourceMappingURL=usePipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePipe.js","sourceRoot":"","sources":["../../../src/decorators/usePipe.ts"],"names":[],"mappings":";;;AAEA,6CAAqC;AAErC;;;;;;;;;GASG;AACH,SAAgB,OAAO,CAAC,KAAwB,EAAE,UAAe,EAAE;IACjE,OAAO,IAAA,oBAAO,EAAC,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;AALD,0BAKC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UseType = void 0;
|
|
4
|
-
const schema_1 = require("@tsed/schema");
|
|
5
|
-
const paramFn_js_1 = require("./paramFn.js");
|
|
6
|
-
function shouldFallBackToAny(entity) {
|
|
7
|
-
if (entity.itemSchema.has("allOf") || entity.itemSchema.has("anyOf") || entity.itemSchema.has("oneOf")) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
return entity.isCollection && entity.type === Object && [undefined, "object"].includes(entity.itemSchema.get("type"));
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Set the type of the item collection.
|
|
14
|
-
*
|
|
15
|
-
* Prefer @@CollectionOf@@ usage.
|
|
16
|
-
*
|
|
17
|
-
* @param useType
|
|
18
|
-
* @decorator
|
|
19
|
-
* @operation
|
|
20
|
-
* @input
|
|
21
|
-
* @alias CollectionOf
|
|
22
|
-
*/
|
|
23
|
-
function UseType(useType) {
|
|
24
|
-
return (0, paramFn_js_1.ParamFn)((entity, parameters) => {
|
|
25
|
-
if (useType) {
|
|
26
|
-
return (0, schema_1.CollectionOf)(useType);
|
|
27
|
-
}
|
|
28
|
-
if (shouldFallBackToAny(entity)) {
|
|
29
|
-
(0, schema_1.Any)()(...parameters);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
exports.UseType = UseType;
|
|
34
|
-
//# sourceMappingURL=useType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useType.js","sourceRoot":"","sources":["../../../src/decorators/useType.ts"],"names":[],"mappings":";;;AACA,yCAAwE;AACxE,6CAAqC;AAErC,SAAS,mBAAmB,CAAC,MAA0B;IACrD,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QACtG,OAAO,KAAK,CAAC;KACd;IAED,OAAO,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,CAAC;AACxH,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,OAAO,CAAC,OAAoC;IAC1D,OAAO,IAAA,oBAAO,EAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;QACpC,IAAI,OAAO,EAAE;YACX,OAAO,IAAA,qBAAY,EAAC,OAAO,CAAC,CAAC;SAC9B;QAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE;YAC/B,IAAA,YAAG,GAAE,CAAC,GAAG,UAAU,CAAC,CAAC;SACtB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,0BAUC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UseValidation = void 0;
|
|
4
|
-
const ValidationPipe_js_1 = require("../pipes/ValidationPipe.js");
|
|
5
|
-
const paramFn_js_1 = require("./paramFn.js");
|
|
6
|
-
/**
|
|
7
|
-
* Enable validation on the decoratored parameter.
|
|
8
|
-
*
|
|
9
|
-
* @decorator
|
|
10
|
-
* @operation
|
|
11
|
-
* @input
|
|
12
|
-
* @pipe
|
|
13
|
-
*/
|
|
14
|
-
function UseValidation() {
|
|
15
|
-
return (0, paramFn_js_1.ParamFn)((param) => {
|
|
16
|
-
if (param.type || param.collectionType) {
|
|
17
|
-
param.pipes.push(ValidationPipe_js_1.ValidationPipe);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
exports.UseValidation = UseValidation;
|
|
22
|
-
//# sourceMappingURL=useValidation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useValidation.js","sourceRoot":"","sources":["../../../src/decorators/useValidation.ts"],"names":[],"mappings":";;;AAAA,kEAA0D;AAC1D,6CAAqC;AAErC;;;;;;;GAOG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAA,oBAAO,EAAC,CAAC,KAAK,EAAE,EAAE;QACvB,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,cAAc,EAAE;YACtC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,kCAAc,CAAC,CAAC;SAClC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAND,sCAMC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParamMetadata = void 0;
|
|
4
|
-
var schema_1 = require("@tsed/schema");
|
|
5
|
-
Object.defineProperty(exports, "ParamMetadata", { enumerable: true, get: function () { return schema_1.ParamMetadata; } });
|
|
6
|
-
//# sourceMappingURL=ParamMetadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParamMetadata.js","sourceRoot":"","sources":["../../../src/domain/ParamMetadata.ts"],"names":[],"mappings":";;;AAAA,uCAA2C;AAAnC,uGAAA,aAAa,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParamOptions.js","sourceRoot":"","sources":["../../../src/domain/ParamOptions.ts"],"names":[],"mappings":""}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PARAM_TYPES_DATA_PATH = exports.ParamTypes = void 0;
|
|
4
|
-
var ParamTypes;
|
|
5
|
-
(function (ParamTypes) {
|
|
6
|
-
ParamTypes["$CTX"] = "$CTX";
|
|
7
|
-
ParamTypes["BODY"] = "BODY";
|
|
8
|
-
ParamTypes["PATH"] = "PATH";
|
|
9
|
-
ParamTypes["QUERY"] = "QUERY";
|
|
10
|
-
ParamTypes["HEADER"] = "HEADER";
|
|
11
|
-
ParamTypes["RAW_BODY"] = "RAW_BODY";
|
|
12
|
-
ParamTypes["COOKIES"] = "COOKIES";
|
|
13
|
-
ParamTypes["LOCALS"] = "LOCALS";
|
|
14
|
-
ParamTypes["SESSION"] = "SESSION";
|
|
15
|
-
ParamTypes["FILES"] = "FILES";
|
|
16
|
-
/// NOT STD
|
|
17
|
-
ParamTypes["NEXT_FN"] = "NEXT_FN";
|
|
18
|
-
ParamTypes["ERR"] = "ERR";
|
|
19
|
-
ParamTypes["REQUEST"] = "REQUEST";
|
|
20
|
-
ParamTypes["PLATFORM_REQUEST"] = "PLATFORM_REQUEST";
|
|
21
|
-
ParamTypes["NODE_REQUEST"] = "NODE_REQUEST";
|
|
22
|
-
ParamTypes["RESPONSE"] = "RESPONSE";
|
|
23
|
-
ParamTypes["PLATFORM_RESPONSE"] = "PLATFORM_RESPONSE";
|
|
24
|
-
ParamTypes["NODE_RESPONSE"] = "NODE_RESPONSE";
|
|
25
|
-
ParamTypes["RESPONSE_DATA"] = "RESPONSE_DATA";
|
|
26
|
-
ParamTypes["ENDPOINT_INFO"] = "ENDPOINT_INFO";
|
|
27
|
-
ParamTypes["RES"] = "RES";
|
|
28
|
-
ParamTypes["REQ"] = "REQ";
|
|
29
|
-
})(ParamTypes = exports.ParamTypes || (exports.ParamTypes = {}));
|
|
30
|
-
exports.PARAM_TYPES_DATA_PATH = {
|
|
31
|
-
[ParamTypes.HEADER]: "$ctx.request.headers",
|
|
32
|
-
[ParamTypes.RAW_BODY]: "$ctx.request.rawBody",
|
|
33
|
-
[ParamTypes.BODY]: "$ctx.request.body",
|
|
34
|
-
[ParamTypes.QUERY]: "$ctx.request.query",
|
|
35
|
-
[ParamTypes.PATH]: "$ctx.request.params",
|
|
36
|
-
[ParamTypes.COOKIES]: "$ctx.request.cookies",
|
|
37
|
-
[ParamTypes.SESSION]: "$ctx.request.session",
|
|
38
|
-
[ParamTypes.LOCALS]: "$ctx.response.locals"
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=ParamTypes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParamTypes.js","sourceRoot":"","sources":["../../../src/domain/ParamTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAyBX;AAzBD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IAEf,WAAW;IACX,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,iCAAmB,CAAA;IACnB,mDAAqC,CAAA;IACrC,2CAA6B,CAAA;IAC7B,mCAAqB,CAAA;IACrB,qDAAuC,CAAA;IACvC,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,yBAAW,CAAA;IACX,yBAAW,CAAA;AACb,CAAC,EAzBW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAyBrB;AAEY,QAAA,qBAAqB,GAA2B;IAC3D,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;IAC3C,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,sBAAsB;IAC7C,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,mBAAmB;IACtC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,oBAAoB;IACxC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,qBAAqB;IACxC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;CAC5C,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParamValidationError = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const exceptions_1 = require("@tsed/exceptions");
|
|
6
|
-
const ValidationError_js_1 = require("./ValidationError.js");
|
|
7
|
-
class ParamValidationError extends exceptions_1.BadRequest {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
this.name = "PARAM_VALIDATION_ERROR";
|
|
11
|
-
}
|
|
12
|
-
static from(metadata, origin = {}) {
|
|
13
|
-
if (origin instanceof ValidationError_js_1.ValidationError || origin instanceof exceptions_1.BadRequest) {
|
|
14
|
-
const name = (0, core_1.nameOf)(metadata.paramType)
|
|
15
|
-
.toLowerCase()
|
|
16
|
-
.replace(/parse|params|filter/gi, "");
|
|
17
|
-
const expression = metadata.expression;
|
|
18
|
-
const dataPath = `${name}${expression ? "." + expression : ""}`;
|
|
19
|
-
const message = `Bad request on parameter "request.${dataPath}".\n${origin.message}`.trim();
|
|
20
|
-
const error = new ParamValidationError(message);
|
|
21
|
-
error.dataPath = String(metadata.expression) || "";
|
|
22
|
-
error.requestType = (0, core_1.nameOf)(metadata.paramType);
|
|
23
|
-
error.origin = origin.origin || origin;
|
|
24
|
-
if (error.origin?.errors) {
|
|
25
|
-
error.origin?.errors.forEach((error) => {
|
|
26
|
-
error.requestPath = name;
|
|
27
|
-
error.dataPath = error.dataPath || (expression ? `.${expression}` : "");
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return error;
|
|
31
|
-
}
|
|
32
|
-
return origin;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ParamValidationError = ParamValidationError;
|
|
36
|
-
//# sourceMappingURL=ParamValidationError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParamValidationError.js","sourceRoot":"","sources":["../../../src/errors/ParamValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,iDAA4C;AAE5C,6DAAqD;AAErD,MAAa,oBAAqB,SAAQ,uBAAU;IAApD;;QACS,SAAI,GAAW,wBAAwB,CAAC;IA8BjD,CAAC;IA1BC,MAAM,CAAC,IAAI,CAAC,QAA4B,EAAE,SAAc,EAAE;QACxD,IAAI,MAAM,YAAY,oCAAe,IAAI,MAAM,YAAY,uBAAU,EAAE;YACrE,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,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,QAAQ,GAAG,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAChE,MAAM,OAAO,GAAG,qCAAqC,QAAQ,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YAE5F,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,IAAA,aAAM,EAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC/C,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC;YAEvC,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE;gBACxB,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;oBAC1C,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;oBACzB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC1E,CAAC,CAAC,CAAC;aACJ;YAED,OAAO,KAAK,CAAC;SACd;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/BD,oDA+BC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequiredValidationError = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const ValidationError_js_1 = require("./ValidationError.js");
|
|
6
|
-
class RequiredValidationError extends ValidationError_js_1.ValidationError {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.name = "REQUIRED_VALIDATION_ERROR";
|
|
10
|
-
}
|
|
11
|
-
static from(metadata) {
|
|
12
|
-
const name = (0, core_1.nameOf)(metadata.paramType);
|
|
13
|
-
const expression = metadata.expression;
|
|
14
|
-
const type = name.toLowerCase().replace(/parse|params|filter/gi, "");
|
|
15
|
-
const message = `It should have required parameter '${expression}'`;
|
|
16
|
-
const errors = [
|
|
17
|
-
{
|
|
18
|
-
dataPath: "",
|
|
19
|
-
keyword: "required",
|
|
20
|
-
message,
|
|
21
|
-
modelName: type,
|
|
22
|
-
params: {
|
|
23
|
-
missingProperty: expression
|
|
24
|
-
},
|
|
25
|
-
schemaPath: "#/required"
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
return new RequiredValidationError(message, errors);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.RequiredValidationError = RequiredValidationError;
|
|
32
|
-
//# sourceMappingURL=RequiredValidationError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequiredValidationError.js","sourceRoot":"","sources":["../../../src/errors/RequiredValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,6DAAqD;AAGrD,MAAa,uBAAwB,SAAQ,oCAAe;IAA5D;;QACS,SAAI,GAAW,2BAA2B,CAAC;IAuBpD,CAAC;IArBC,MAAM,CAAC,IAAI,CAAC,QAA4B;QACtC,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,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;AAxBD,0DAwBC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationError = void 0;
|
|
4
|
-
const exceptions_1 = require("@tsed/exceptions");
|
|
5
|
-
class ValidationError extends exceptions_1.BadRequest {
|
|
6
|
-
constructor(message, errors = []) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = "VALIDATION_ERROR";
|
|
9
|
-
this.errors = errors;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.ValidationError = ValidationError;
|
|
13
|
-
//# sourceMappingURL=ValidationError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationError.js","sourceRoot":"","sources":["../../../src/errors/ValidationError.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C,MAAa,eAAgB,SAAQ,uBAAU;IAI7C,YAAY,OAAe,EAAE,SAAgB,EAAE;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QAJV,SAAI,GAAW,kBAAkB,CAAC;QAKvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AARD,0CAQC"}
|
package/lib/cjs/exports.js
DELETED
package/lib/cjs/exports.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":""}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* @file Automatically generated by @tsed/barrels.
|
|
6
|
-
*/
|
|
7
|
-
tslib_1.__exportStar(require("./builder/PlatformParams.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./decorators/bodyParams.js"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./decorators/context.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./decorators/cookies.js"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./decorators/headerParams.js"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./decorators/locals.js"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./decorators/paramFn.js"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./decorators/pathParams.js"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./decorators/queryParams.js"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./decorators/session.js"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./decorators/useDeserialization.js"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./decorators/useParam.js"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./decorators/useParamExpression.js"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./decorators/useParamType.js"), exports);
|
|
21
|
-
tslib_1.__exportStar(require("./decorators/usePipe.js"), exports);
|
|
22
|
-
tslib_1.__exportStar(require("./decorators/useType.js"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./decorators/useValidation.js"), exports);
|
|
24
|
-
tslib_1.__exportStar(require("./domain/ParamMetadata.js"), exports);
|
|
25
|
-
tslib_1.__exportStar(require("./domain/ParamOptions.js"), exports);
|
|
26
|
-
tslib_1.__exportStar(require("./domain/ParamTypes.js"), exports);
|
|
27
|
-
tslib_1.__exportStar(require("./errors/ParamValidationError.js"), exports);
|
|
28
|
-
tslib_1.__exportStar(require("./errors/RequiredValidationError.js"), exports);
|
|
29
|
-
tslib_1.__exportStar(require("./errors/ValidationError.js"), exports);
|
|
30
|
-
tslib_1.__exportStar(require("./exports.js"), exports);
|
|
31
|
-
tslib_1.__exportStar(require("./pipes/DeserializerPipe.js"), exports);
|
|
32
|
-
tslib_1.__exportStar(require("./pipes/ParseExpressionPipe.js"), exports);
|
|
33
|
-
tslib_1.__exportStar(require("./pipes/ValidationPipe.js"), exports);
|
|
34
|
-
tslib_1.__exportStar(require("./utils/mapParamsOptions.js"), exports);
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,sEAA4C;AAC5C,qEAA2C;AAC3C,kEAAwC;AACxC,kEAAwC;AACxC,uEAA6C;AAC7C,iEAAuC;AACvC,kEAAwC;AACxC,qEAA2C;AAC3C,sEAA4C;AAC5C,kEAAwC;AACxC,6EAAmD;AACnD,mEAAyC;AACzC,6EAAmD;AACnD,uEAA6C;AAC7C,kEAAwC;AACxC,kEAAwC;AACxC,wEAA8C;AAC9C,oEAA0C;AAC1C,mEAAyC;AACzC,iEAAuC;AACvC,2EAAiD;AACjD,8EAAoD;AACpD,sEAA4C;AAC5C,uDAA6B;AAC7B,sEAA4C;AAC5C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var DeserializerPipe_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.DeserializerPipe = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const json_mapper_1 = require("@tsed/json-mapper");
|
|
8
|
-
let DeserializerPipe = DeserializerPipe_1 = class DeserializerPipe {
|
|
9
|
-
transform(value, param) {
|
|
10
|
-
return (0, json_mapper_1.deserialize)(value, {
|
|
11
|
-
useAlias: true,
|
|
12
|
-
store: param,
|
|
13
|
-
...(param.store.get(DeserializerPipe_1) || {})
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
DeserializerPipe = DeserializerPipe_1 = tslib_1.__decorate([
|
|
18
|
-
(0, di_1.Injectable)()
|
|
19
|
-
], DeserializerPipe);
|
|
20
|
-
exports.DeserializerPipe = DeserializerPipe;
|
|
21
|
-
//# sourceMappingURL=DeserializerPipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeserializerPipe.js","sourceRoot":"","sources":["../../../src/pipes/DeserializerPipe.ts"],"names":[],"mappings":";;;;;AAAA,iCAAoC;AACpC,mDAA8C;AAIvC,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,SAAS,CAAC,KAAU,EAAE,KAAyB;QAC7C,OAAO,IAAA,yBAAW,EAAC,KAAK,EAAE;YACxB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,KAAK;YACZ,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAgB,CAAC,IAAI,EAAE,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AARY,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAQ5B;AARY,4CAAgB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParseExpressionPipe = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const ParamTypes_js_1 = require("../domain/ParamTypes.js");
|
|
8
|
-
let ParseExpressionPipe = class ParseExpressionPipe {
|
|
9
|
-
transform(scope, param) {
|
|
10
|
-
const { paramType, type } = param;
|
|
11
|
-
const value = (0, core_1.getValue)(scope, this.getKey(param));
|
|
12
|
-
if ([ParamTypes_js_1.ParamTypes.QUERY, ParamTypes_js_1.ParamTypes.PATH].includes(paramType) && value === "" && type !== String) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
getKey(param) {
|
|
18
|
-
let { expression, paramType, dataPath } = param;
|
|
19
|
-
paramType = paramType || param.parameter.get("in").toUpperCase();
|
|
20
|
-
if (expression && paramType === ParamTypes_js_1.ParamTypes.HEADER) {
|
|
21
|
-
expression = String(expression).toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
return [dataPath, expression].filter(Boolean).join(".");
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
ParseExpressionPipe = tslib_1.__decorate([
|
|
27
|
-
(0, di_1.Injectable)({
|
|
28
|
-
priority: -1000
|
|
29
|
-
})
|
|
30
|
-
], ParseExpressionPipe);
|
|
31
|
-
exports.ParseExpressionPipe = ParseExpressionPipe;
|
|
32
|
-
//# sourceMappingURL=ParseExpressionPipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParseExpressionPipe.js","sourceRoot":"","sources":["../../../src/pipes/ParseExpressionPipe.ts"],"names":[],"mappings":";;;;AAAA,qCAAoC;AACpC,iCAAoC;AAGpC,2DAAmD;AAK5C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,SAAS,CAAC,KAA0B,EAAE,KAAyB;QAC7D,MAAM,EAAC,SAAS,EAAE,IAAI,EAAC,GAAG,KAAK,CAAC;QAEhC,MAAM,KAAK,GAAG,IAAA,eAAQ,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,IAAI,CAAC,0BAAU,CAAC,KAAK,EAAE,0BAAU,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,0BAAU,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,IAAA,eAAU,EAAC;QACV,QAAQ,EAAE,CAAC,IAAI;KAChB,CAAC;GACW,mBAAmB,CAuB/B;AAvBY,kDAAmB"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationPipe = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@tsed/di");
|
|
6
|
-
const json_mapper_1 = require("@tsed/json-mapper");
|
|
7
|
-
const schema_1 = require("@tsed/schema");
|
|
8
|
-
const ParamTypes_js_1 = require("../domain/ParamTypes.js");
|
|
9
|
-
const RequiredValidationError_js_1 = require("../errors/RequiredValidationError.js");
|
|
10
|
-
function cast(value, metadata) {
|
|
11
|
-
try {
|
|
12
|
-
return (0, json_mapper_1.deserialize)(value, {
|
|
13
|
-
type: metadata.type
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
catch (er) {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
let ValidationPipe = class ValidationPipe {
|
|
21
|
-
constructor(validators) {
|
|
22
|
-
this.validator = validators[0];
|
|
23
|
-
}
|
|
24
|
-
coerceTypes(value, metadata) {
|
|
25
|
-
if (value === undefined) {
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
if (value === "null") {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
if (metadata.isArray) {
|
|
32
|
-
return [].concat(value);
|
|
33
|
-
}
|
|
34
|
-
if (metadata.isPrimitive) {
|
|
35
|
-
return cast(value, metadata);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
skip(value, metadata) {
|
|
40
|
-
return metadata.paramType === ParamTypes_js_1.ParamTypes.PATH && !metadata.isPrimitive;
|
|
41
|
-
}
|
|
42
|
-
transform(value, metadata) {
|
|
43
|
-
if (!this.validator) {
|
|
44
|
-
this.checkIsRequired(value, metadata);
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
// FIXME See if it's necessary ?
|
|
48
|
-
if (this.skip(value, metadata)) {
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
value = this.coerceTypes(value, metadata);
|
|
52
|
-
this.checkIsRequired(value, metadata);
|
|
53
|
-
if (value === undefined) {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
const schema = (0, schema_1.getJsonSchema)(metadata, {
|
|
57
|
-
customKeys: true
|
|
58
|
-
});
|
|
59
|
-
return this.validator.validate(value, {
|
|
60
|
-
schema,
|
|
61
|
-
type: metadata.isClass ? metadata.type : undefined,
|
|
62
|
-
collectionType: metadata.collectionType
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
checkIsRequired(value, metadata) {
|
|
66
|
-
if (metadata.isRequired(value)) {
|
|
67
|
-
throw RequiredValidationError_js_1.RequiredValidationError.from(metadata);
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
ValidationPipe = tslib_1.__decorate([
|
|
73
|
-
(0, di_1.Injectable)({
|
|
74
|
-
type: "validator"
|
|
75
|
-
}),
|
|
76
|
-
tslib_1.__param(0, (0, di_1.Inject)("validator:service")),
|
|
77
|
-
tslib_1.__metadata("design:paramtypes", [Array])
|
|
78
|
-
], ValidationPipe);
|
|
79
|
-
exports.ValidationPipe = ValidationPipe;
|
|
80
|
-
//# sourceMappingURL=ValidationPipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.ts"],"names":[],"mappings":";;;;AAAA,iCAA4C;AAC5C,mDAA8C;AAC9C,yCAA4E;AAC5E,2DAAmD;AACnD,qFAA6E;AAE7E,SAAS,IAAI,CAAC,KAAU,EAAE,QAA4B;IACpD,IAAI;QACF,OAAO,IAAA,yBAAW,EAAC,KAAK,EAAE;YACxB,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC,CAAC;KACJ;IAAC,OAAO,EAAE,EAAE;QACX,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAOM,IAAM,cAAc,GAApB,MAAM,cAAc;IAGzB,YAAyC,UAAqC;QAC5E,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,WAAW,CAAC,KAAU,EAAE,QAA4B;QAClD,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,KAAK,KAAK,MAAM,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QAED,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACzB;QAED,IAAI,QAAQ,CAAC,WAAW,EAAE;YACxB,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;SAC9B;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,KAAU,EAAE,QAA4B;QAC3C,OAAO,QAAQ,CAAC,SAAS,KAAK,0BAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACzE,CAAC;IAED,SAAS,CAAC,KAAU,EAAE,QAA4B;QAChD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC;SACd;QAED,gCAAgC;QAChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;YAC9B,OAAO,KAAK,CAAC;SACd;QAED,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAEtC,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,OAAO,KAAK,CAAC;SACd;QAED,MAAM,MAAM,GAAG,IAAA,sBAAa,EAAC,QAAQ,EAAE;YACrC,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE;YACpC,MAAM;YACN,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YAClD,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC,CAAC,CAAC;IACL,CAAC;IAES,eAAe,CAAC,KAAU,EAAE,QAA4B;QAChE,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9B,MAAM,oDAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC9C;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AApEY,cAAc;IAH1B,IAAA,eAAU,EAAC;QACV,IAAI,EAAE,WAAW;KAClB,CAAC;IAIa,mBAAA,IAAA,WAAM,EAAC,mBAAmB,CAAC,CAAA;;GAH7B,cAAc,CAoE1B;AApEY,wCAAc"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapParamsOptions = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
*/
|
|
8
|
-
function mapParamsOptions(args) {
|
|
9
|
-
if (args.length === 1) {
|
|
10
|
-
if (typeof args[0] === "string") {
|
|
11
|
-
return {
|
|
12
|
-
expression: args[0]
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
if (!(0, core_1.isObject)(args[0])) {
|
|
16
|
-
return {
|
|
17
|
-
useType: args[0]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const opts = args[0];
|
|
21
|
-
return {
|
|
22
|
-
...opts,
|
|
23
|
-
useMapper: opts.useMapper
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
expression: args[0],
|
|
28
|
-
useType: args[1]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.mapParamsOptions = mapParamsOptions;
|
|
32
|
-
//# sourceMappingURL=mapParamsOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapParamsOptions.js","sourceRoot":"","sources":["../../../src/utils/mapParamsOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAGpC;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAW;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC/B,OAAO;gBACL,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;aACpB,CAAC;SACH;QAED,IAAI,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YACtB,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;aACjB,CAAC;SACH;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAiB,CAAC;QAErC,OAAO;YACL,GAAG,IAAI;YACP,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;KACH;IAED,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QACnB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC;AA1BD,4CA0BC"}
|
package/lib/esm/package.json
DELETED