@tsed/platform-params 6.88.1 → 6.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{builder → cjs/builder}/PlatformParams.d.ts +0 -0
- package/lib/cjs/builder/PlatformParams.js +79 -0
- package/lib/cjs/builder/PlatformParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/bodyParams.d.ts +0 -0
- package/lib/cjs/decorators/bodyParams.js +53 -0
- package/lib/cjs/decorators/bodyParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/context.d.ts +0 -0
- package/lib/cjs/decorators/context.js +19 -0
- package/lib/cjs/decorators/context.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/cookies.d.ts +0 -0
- package/lib/cjs/decorators/cookies.js +24 -0
- package/lib/cjs/decorators/cookies.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/headerParams.d.ts +0 -0
- package/lib/cjs/decorators/headerParams.js +19 -0
- package/lib/cjs/decorators/headerParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/locals.d.ts +0 -0
- package/lib/cjs/decorators/locals.js +19 -0
- package/lib/cjs/decorators/locals.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/paramFn.d.ts +0 -0
- package/lib/cjs/decorators/paramFn.js +22 -0
- package/lib/cjs/decorators/paramFn.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/pathParams.d.ts +0 -0
- package/lib/cjs/decorators/pathParams.js +55 -0
- package/lib/cjs/decorators/pathParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/queryParams.d.ts +0 -0
- package/lib/cjs/decorators/queryParams.js +55 -0
- package/lib/cjs/decorators/queryParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/session.d.ts +0 -0
- package/lib/cjs/decorators/session.js +19 -0
- package/lib/cjs/decorators/session.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useDeserialization.d.ts +0 -0
- package/lib/cjs/decorators/useDeserialization.js +18 -0
- package/lib/cjs/decorators/useDeserialization.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useParam.d.ts +0 -0
- package/lib/cjs/decorators/useParam.js +38 -0
- package/lib/cjs/decorators/useParam.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useParamExpression.d.ts +0 -0
- package/lib/cjs/decorators/useParamExpression.js +20 -0
- package/lib/cjs/decorators/useParamExpression.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useParamType.d.ts +0 -0
- package/lib/cjs/decorators/useParamType.js +26 -0
- package/lib/cjs/decorators/useParamType.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/usePipe.d.ts +0 -0
- package/lib/cjs/decorators/usePipe.js +22 -0
- package/lib/cjs/decorators/usePipe.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useType.d.ts +0 -0
- package/lib/cjs/decorators/useType.js +20 -0
- package/lib/cjs/decorators/useType.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useValidation.d.ts +0 -0
- package/lib/cjs/decorators/useValidation.js +22 -0
- package/lib/cjs/decorators/useValidation.js.map +1 -0
- package/lib/{domain → cjs/domain}/ParamMetadata.d.ts +0 -0
- package/lib/cjs/domain/ParamMetadata.js +34 -0
- package/lib/cjs/domain/ParamMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/ParamOptions.d.ts +0 -0
- package/lib/cjs/domain/ParamOptions.js +3 -0
- package/lib/cjs/domain/ParamOptions.js.map +1 -0
- package/lib/{domain → cjs/domain}/ParamTypes.d.ts +0 -0
- package/lib/cjs/domain/ParamTypes.js +30 -0
- package/lib/cjs/domain/ParamTypes.js.map +1 -0
- package/lib/{errors → cjs/errors}/ParamValidationError.d.ts +0 -0
- package/lib/cjs/errors/ParamValidationError.js +29 -0
- package/lib/cjs/errors/ParamValidationError.js.map +1 -0
- package/lib/{errors → cjs/errors}/RequiredValidationError.d.ts +0 -1
- package/lib/cjs/errors/RequiredValidationError.js +32 -0
- package/lib/cjs/errors/RequiredValidationError.js.map +1 -0
- package/lib/{errors → cjs/errors}/ValidationError.d.ts +0 -0
- package/lib/cjs/errors/ValidationError.js +13 -0
- package/lib/cjs/errors/ValidationError.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +37 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{pipes → cjs/pipes}/DeserializerPipe.d.ts +0 -0
- package/lib/cjs/pipes/DeserializerPipe.js +30 -0
- package/lib/cjs/pipes/DeserializerPipe.js.map +1 -0
- package/lib/{pipes → cjs/pipes}/ParseExpressionPipe.d.ts +0 -0
- package/lib/cjs/pipes/ParseExpressionPipe.js +24 -0
- package/lib/cjs/pipes/ParseExpressionPipe.js.map +1 -0
- package/lib/{pipes → cjs/pipes}/ValidationPipe.d.ts +0 -0
- package/lib/cjs/pipes/ValidationPipe.js +80 -0
- package/lib/cjs/pipes/ValidationPipe.js.map +1 -0
- package/lib/{utils → cjs/utils}/mapParamsOptions.d.ts +0 -0
- package/lib/cjs/utils/mapParamsOptions.js +30 -0
- package/lib/cjs/utils/mapParamsOptions.js.map +1 -0
- package/lib/esm/builder/PlatformParams.js +76 -0
- package/lib/esm/builder/PlatformParams.js.map +1 -0
- package/lib/esm/decorators/bodyParams.js +48 -0
- package/lib/esm/decorators/bodyParams.js.map +1 -0
- package/lib/esm/decorators/context.js +15 -0
- package/lib/esm/decorators/context.js.map +1 -0
- package/lib/esm/decorators/cookies.js +19 -0
- package/lib/esm/decorators/cookies.js.map +1 -0
- package/lib/esm/decorators/headerParams.js +15 -0
- package/lib/esm/decorators/headerParams.js.map +1 -0
- package/lib/esm/decorators/locals.js +15 -0
- package/lib/esm/decorators/locals.js.map +1 -0
- package/lib/esm/decorators/paramFn.js +18 -0
- package/lib/esm/decorators/paramFn.js.map +1 -0
- package/lib/esm/decorators/pathParams.js +50 -0
- package/lib/esm/decorators/pathParams.js.map +1 -0
- package/lib/esm/decorators/queryParams.js +50 -0
- package/lib/esm/decorators/queryParams.js.map +1 -0
- package/lib/esm/decorators/session.js +15 -0
- package/lib/esm/decorators/session.js.map +1 -0
- package/lib/esm/decorators/useDeserialization.js +14 -0
- package/lib/esm/decorators/useDeserialization.js.map +1 -0
- package/lib/esm/decorators/useParam.js +34 -0
- package/lib/esm/decorators/useParam.js.map +1 -0
- package/lib/esm/decorators/useParamExpression.js +16 -0
- package/lib/esm/decorators/useParamExpression.js.map +1 -0
- package/lib/esm/decorators/useParamType.js +22 -0
- package/lib/esm/decorators/useParamType.js.map +1 -0
- package/lib/esm/decorators/usePipe.js +18 -0
- package/lib/esm/decorators/usePipe.js.map +1 -0
- package/lib/esm/decorators/useType.js +16 -0
- package/lib/esm/decorators/useType.js.map +1 -0
- package/lib/esm/decorators/useValidation.js +18 -0
- package/lib/esm/decorators/useValidation.js.map +1 -0
- package/lib/esm/domain/ParamMetadata.js +31 -0
- package/lib/esm/domain/ParamMetadata.js.map +1 -0
- package/lib/esm/domain/ParamOptions.js +2 -0
- package/lib/esm/domain/ParamOptions.js.map +1 -0
- package/lib/esm/domain/ParamTypes.js +27 -0
- package/lib/esm/domain/ParamTypes.js.map +1 -0
- package/lib/esm/errors/ParamValidationError.js +25 -0
- package/lib/esm/errors/ParamValidationError.js.map +1 -0
- package/lib/esm/errors/RequiredValidationError.js +28 -0
- package/lib/esm/errors/RequiredValidationError.js.map +1 -0
- package/lib/esm/errors/ValidationError.js +9 -0
- package/lib/esm/errors/ValidationError.js.map +1 -0
- package/lib/esm/index.js +34 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/pipes/DeserializerPipe.js +27 -0
- package/lib/esm/pipes/DeserializerPipe.js.map +1 -0
- package/lib/esm/pipes/ParseExpressionPipe.js +21 -0
- package/lib/esm/pipes/ParseExpressionPipe.js.map +1 -0
- package/lib/esm/pipes/ValidationPipe.js +77 -0
- package/lib/esm/pipes/ValidationPipe.js.map +1 -0
- package/lib/esm/utils/mapParamsOptions.js +26 -0
- package/lib/esm/utils/mapParamsOptions.js.map +1 -0
- package/lib/types/builder/PlatformParams.d.ts +23 -0
- package/lib/types/decorators/bodyParams.d.ts +64 -0
- package/lib/types/decorators/context.d.ts +59 -0
- package/lib/types/decorators/cookies.d.ts +81 -0
- package/lib/types/decorators/headerParams.d.ts +33 -0
- package/lib/types/decorators/locals.d.ts +42 -0
- package/lib/types/decorators/paramFn.d.ts +11 -0
- package/lib/types/decorators/pathParams.d.ts +68 -0
- package/lib/types/decorators/queryParams.d.ts +73 -0
- package/lib/types/decorators/session.d.ts +36 -0
- package/lib/types/decorators/useDeserialization.d.ts +9 -0
- package/lib/types/decorators/useParam.d.ts +22 -0
- package/lib/types/decorators/useParamExpression.d.ts +10 -0
- package/lib/types/decorators/useParamType.d.ts +10 -0
- package/lib/types/decorators/usePipe.d.ts +13 -0
- package/lib/types/decorators/useType.d.ts +13 -0
- package/lib/types/decorators/useValidation.d.ts +9 -0
- package/lib/types/domain/ParamMetadata.d.ts +16 -0
- package/lib/types/domain/ParamOptions.d.ts +10 -0
- package/lib/types/domain/ParamTypes.d.ts +24 -0
- package/lib/types/errors/ParamValidationError.d.ts +8 -0
- package/lib/types/errors/RequiredValidationError.d.ts +6 -0
- package/lib/types/errors/ValidationError.d.ts +6 -0
- package/lib/types/index.d.ts +28 -0
- package/lib/types/pipes/DeserializerPipe.d.ts +5 -0
- package/lib/types/pipes/ParseExpressionPipe.d.ts +5 -0
- package/lib/types/pipes/ValidationPipe.d.ts +10 -0
- package/lib/types/utils/mapParamsOptions.d.ts +5 -0
- package/package.json +20 -16
- package/tsconfig.compile.esm.json +23 -0
- package/lib/index.js +0 -807
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -788
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
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 };
|
|
31
|
+
//# sourceMappingURL=ParamMetadata.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParamOptions.js","sourceRoot":"","sources":["../../../src/domain/ParamOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\n\nexport interface ParamOptions<T = any> {\n dataPath: string;\n paramType: string;\n expression?: string;\n useType?: Type<T>;\n useConverter?: boolean;\n useValidation?: boolean;\n\n [key: string]: any;\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export var ParamTypes;
|
|
2
|
+
(function (ParamTypes) {
|
|
3
|
+
ParamTypes["$CTX"] = "$CTX";
|
|
4
|
+
ParamTypes["BODY"] = "BODY";
|
|
5
|
+
ParamTypes["PATH"] = "PATH";
|
|
6
|
+
ParamTypes["QUERY"] = "QUERY";
|
|
7
|
+
ParamTypes["HEADER"] = "HEADER";
|
|
8
|
+
ParamTypes["RAW_BODY"] = "RAW_BODY";
|
|
9
|
+
ParamTypes["COOKIES"] = "COOKIES";
|
|
10
|
+
ParamTypes["LOCALS"] = "LOCALS";
|
|
11
|
+
ParamTypes["SESSION"] = "SESSION";
|
|
12
|
+
ParamTypes["FILES"] = "FILES";
|
|
13
|
+
/// NOT STD
|
|
14
|
+
ParamTypes["NEXT_FN"] = "NEXT_FN";
|
|
15
|
+
ParamTypes["ERR"] = "ERR";
|
|
16
|
+
ParamTypes["REQUEST"] = "REQUEST";
|
|
17
|
+
ParamTypes["PLATFORM_REQUEST"] = "PLATFORM_REQUEST";
|
|
18
|
+
ParamTypes["NODE_REQUEST"] = "NODE_REQUEST";
|
|
19
|
+
ParamTypes["RESPONSE"] = "RESPONSE";
|
|
20
|
+
ParamTypes["PLATFORM_RESPONSE"] = "PLATFORM_RESPONSE";
|
|
21
|
+
ParamTypes["NODE_RESPONSE"] = "NODE_RESPONSE";
|
|
22
|
+
ParamTypes["RESPONSE_DATA"] = "RESPONSE_DATA";
|
|
23
|
+
ParamTypes["ENDPOINT_INFO"] = "ENDPOINT_INFO";
|
|
24
|
+
ParamTypes["RES"] = "RES";
|
|
25
|
+
ParamTypes["REQ"] = "REQ";
|
|
26
|
+
})(ParamTypes || (ParamTypes = {}));
|
|
27
|
+
//# sourceMappingURL=ParamTypes.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { nameOf } from "@tsed/core";
|
|
2
|
+
import { BadRequest } from "@tsed/exceptions";
|
|
3
|
+
import { ValidationError } from "./ValidationError";
|
|
4
|
+
export class ParamValidationError extends BadRequest {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.name = "PARAM_VALIDATION_ERROR";
|
|
8
|
+
}
|
|
9
|
+
static from(metadata, origin = {}) {
|
|
10
|
+
if (origin instanceof ValidationError || origin instanceof BadRequest) {
|
|
11
|
+
const name = nameOf(metadata.paramType)
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.replace(/parse|params|filter/gi, "");
|
|
14
|
+
const expression = metadata.expression;
|
|
15
|
+
const message = `Bad request on parameter "request.${name}${expression ? "." + expression : ""}".\n${origin.message}`.trim();
|
|
16
|
+
const error = new ParamValidationError(message);
|
|
17
|
+
error.dataPath = String(metadata.expression) || "";
|
|
18
|
+
error.requestType = nameOf(metadata.paramType);
|
|
19
|
+
error.origin = origin.origin || origin;
|
|
20
|
+
return error;
|
|
21
|
+
}
|
|
22
|
+
return origin;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ParamValidationError.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { nameOf } from "@tsed/core";
|
|
2
|
+
import { ValidationError } from "./ValidationError";
|
|
3
|
+
export class RequiredValidationError extends ValidationError {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "REQUIRED_VALIDATION_ERROR";
|
|
7
|
+
}
|
|
8
|
+
static from(metadata) {
|
|
9
|
+
const name = nameOf(metadata.paramType);
|
|
10
|
+
const expression = metadata.expression;
|
|
11
|
+
const type = name.toLowerCase().replace(/parse|params|filter/gi, "");
|
|
12
|
+
const message = `It should have required parameter '${expression}'`;
|
|
13
|
+
const errors = [
|
|
14
|
+
{
|
|
15
|
+
dataPath: "",
|
|
16
|
+
keyword: "required",
|
|
17
|
+
message,
|
|
18
|
+
modelName: type,
|
|
19
|
+
params: {
|
|
20
|
+
missingProperty: expression
|
|
21
|
+
},
|
|
22
|
+
schemaPath: "#/required"
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
return new RequiredValidationError(message, errors);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=RequiredValidationError.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BadRequest } from "@tsed/exceptions";
|
|
2
|
+
export class ValidationError extends BadRequest {
|
|
3
|
+
constructor(message, errors = []) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "VALIDATION_ERROR";
|
|
6
|
+
this.errors = errors;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationError.js","sourceRoot":"","sources":["../../../src/errors/ValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE5C,MAAM,OAAO,eAAgB,SAAQ,UAAU;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","sourcesContent":["import {BadRequest} from \"@tsed/exceptions\";\n\nexport class ValidationError extends BadRequest {\n public name: string = \"VALIDATION_ERROR\";\n public errors: any[];\n\n constructor(message: string, errors: any[] = []) {\n super(message);\n this.errors = errors;\n }\n}\n"]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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";
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var DeserializerPipe_1;
|
|
2
|
+
import { __decorate, __metadata } from "tslib";
|
|
3
|
+
import { Constant, Injectable } from "@tsed/di";
|
|
4
|
+
import { deserialize } from "@tsed/json-mapper";
|
|
5
|
+
let DeserializerPipe = DeserializerPipe_1 = class DeserializerPipe {
|
|
6
|
+
transform(value, param) {
|
|
7
|
+
return deserialize(value, {
|
|
8
|
+
useAlias: true,
|
|
9
|
+
additionalProperties: this.settings.additionalProperties === "accept",
|
|
10
|
+
type: param.type,
|
|
11
|
+
collectionType: param.collectionType,
|
|
12
|
+
groups: param.parameter.groups,
|
|
13
|
+
genericTypes: param.nestedGenerics[0],
|
|
14
|
+
nestedGenerics: param.nestedGenerics,
|
|
15
|
+
...(param.store.get(DeserializerPipe_1) || {})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
__decorate([
|
|
20
|
+
Constant("converter", {}),
|
|
21
|
+
__metadata("design:type", Object)
|
|
22
|
+
], DeserializerPipe.prototype, "settings", void 0);
|
|
23
|
+
DeserializerPipe = DeserializerPipe_1 = __decorate([
|
|
24
|
+
Injectable()
|
|
25
|
+
], DeserializerPipe);
|
|
26
|
+
export { DeserializerPipe };
|
|
27
|
+
//# sourceMappingURL=DeserializerPipe.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { getValue } from "@tsed/core";
|
|
3
|
+
import { Injectable } from "@tsed/di";
|
|
4
|
+
import { ParamTypes } from "../domain/ParamTypes";
|
|
5
|
+
let ParseExpressionPipe = class ParseExpressionPipe {
|
|
6
|
+
transform(scope, param) {
|
|
7
|
+
const { paramType, type } = param;
|
|
8
|
+
const value = getValue(scope, param.key);
|
|
9
|
+
if ([ParamTypes.QUERY, ParamTypes.PATH].includes(paramType) && value === "" && type !== String) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
ParseExpressionPipe = __decorate([
|
|
16
|
+
Injectable({
|
|
17
|
+
priority: -1000
|
|
18
|
+
})
|
|
19
|
+
], ParseExpressionPipe);
|
|
20
|
+
export { ParseExpressionPipe };
|
|
21
|
+
//# sourceMappingURL=ParseExpressionPipe.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { nameOf } from "@tsed/core";
|
|
3
|
+
import { Injectable, InjectorService } from "@tsed/di";
|
|
4
|
+
import { deserialize } from "@tsed/json-mapper";
|
|
5
|
+
import { getJsonSchema } from "@tsed/schema";
|
|
6
|
+
import { RequiredValidationError } from "../errors/RequiredValidationError";
|
|
7
|
+
import { ParamTypes } from "../domain/ParamTypes";
|
|
8
|
+
let ValidationPipe = class ValidationPipe {
|
|
9
|
+
constructor(injector) {
|
|
10
|
+
const provider = injector.getProviders().find((provider) => nameOf(provider.token) === "AjvService");
|
|
11
|
+
if (provider) {
|
|
12
|
+
this.validator = injector.invoke(provider.token);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
coerceTypes(value, metadata) {
|
|
16
|
+
if (value === undefined) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
if (value === "null") {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (metadata.isPrimitive) {
|
|
23
|
+
try {
|
|
24
|
+
return deserialize(value, {
|
|
25
|
+
type: metadata.type
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (er) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (metadata.isArray) {
|
|
33
|
+
return [].concat(value);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
skip(value, metadata) {
|
|
38
|
+
return metadata.paramType === ParamTypes.PATH && !metadata.isPrimitive;
|
|
39
|
+
}
|
|
40
|
+
async transform(value, metadata) {
|
|
41
|
+
if (!this.validator) {
|
|
42
|
+
this.checkIsRequired(value, metadata);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
if (this.skip(value, metadata)) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
value = this.coerceTypes(value, metadata);
|
|
49
|
+
this.checkIsRequired(value, metadata);
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
const schema = getJsonSchema(metadata, {
|
|
54
|
+
customKeys: true
|
|
55
|
+
});
|
|
56
|
+
await this.validator.validate(value, {
|
|
57
|
+
schema,
|
|
58
|
+
type: metadata.isClass ? metadata.type : undefined,
|
|
59
|
+
collectionType: metadata.collectionType
|
|
60
|
+
});
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
checkIsRequired(value, metadata) {
|
|
64
|
+
if (metadata.isRequired(value)) {
|
|
65
|
+
throw RequiredValidationError.from(metadata);
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
ValidationPipe = __decorate([
|
|
71
|
+
Injectable({
|
|
72
|
+
type: "validator"
|
|
73
|
+
}),
|
|
74
|
+
__metadata("design:paramtypes", [InjectorService])
|
|
75
|
+
], ValidationPipe);
|
|
76
|
+
export { ValidationPipe };
|
|
77
|
+
//# sourceMappingURL=ValidationPipe.js.map
|
|
@@ -0,0 +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 {PipeMethods, ParamMetadata} from \"../domain/ParamMetadata\";\nimport {ParamTypes} from \"../domain/ParamTypes\";\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.isPrimitive) {\n try {\n return deserialize(value, {\n type: metadata.type\n });\n } catch (er) {\n return value;\n }\n }\n\n if (metadata.isArray) {\n return [].concat(value);\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"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isObject } from "@tsed/core";
|
|
2
|
+
/**
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
export function mapParamsOptions(args) {
|
|
6
|
+
if (args.length === 1) {
|
|
7
|
+
if (typeof args[0] === "string") {
|
|
8
|
+
return {
|
|
9
|
+
expression: args[0]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (!isObject(args[0])) {
|
|
13
|
+
return {
|
|
14
|
+
useType: args[0]
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
...args[0]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
expression: args[0],
|
|
23
|
+
useType: args[1]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=mapParamsOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapParamsOptions.js","sourceRoot":"","sources":["../../../src/utils/mapParamsOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAGpC;;GAEG;AACH,MAAM,UAAU,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,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YACtB,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;aACjB,CAAC;SACH;QAED,OAAO;YACL,GAAG,IAAI,CAAC,CAAC,CAAC;SACX,CAAC;KACH;IAED,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QACnB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {ParamOptions} from \"../domain/ParamOptions\";\n\n/**\n * @ignore\n */\nexport function mapParamsOptions(args: any[]): Partial<ParamOptions<any>> {\n if (args.length === 1) {\n if (typeof args[0] === \"string\") {\n return {\n expression: args[0]\n };\n }\n\n if (!isObject(args[0])) {\n return {\n useType: args[0]\n };\n }\n\n return {\n ...args[0]\n };\n }\n\n return {\n expression: args[0],\n useType: args[1]\n };\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DIContext, InjectorService, TokenProvider } from "@tsed/di";
|
|
2
|
+
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
+
import { ParamMetadata, PipeMethods } from "../domain/ParamMetadata";
|
|
4
|
+
export declare type ArgScope<Context extends DIContext = DIContext> = {
|
|
5
|
+
$ctx: Context;
|
|
6
|
+
} & Record<string, any>;
|
|
7
|
+
export declare type HandlerWithScope<Context extends DIContext = DIContext> = (scope: ArgScope<Context>) => any;
|
|
8
|
+
export interface CompileHandlerOptions<Context extends DIContext = DIContext> extends Record<any, unknown> {
|
|
9
|
+
token: TokenProvider;
|
|
10
|
+
propertyKey: string | symbol;
|
|
11
|
+
getCustomArgs?: (scope: ArgScope<Context>) => Promise<any[]>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Platform Params abstraction layer.
|
|
15
|
+
* @platform
|
|
16
|
+
*/
|
|
17
|
+
export declare class PlatformParams {
|
|
18
|
+
protected injector: InjectorService;
|
|
19
|
+
getPipes(param: ParamMetadata): Promise<PipeMethods<any, any>[]>;
|
|
20
|
+
compile<Context extends DIContext = DIContext>(entity: JsonEntityStore): Promise<(scope: ArgScope<Context>) => Promise<any[]>>;
|
|
21
|
+
getArg(scope: ArgScope, pipes: PipeMethods[], param: ParamMetadata): Promise<any>;
|
|
22
|
+
compileHandler<Context extends DIContext = DIContext>(metadata: CompileHandlerOptions<Context>): Promise<HandlerWithScope<Context>>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ParamOptions } from "../domain/ParamOptions";
|
|
3
|
+
/**
|
|
4
|
+
* BodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) object.
|
|
5
|
+
*
|
|
6
|
+
* #### Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller('/')
|
|
10
|
+
* class MyCtrl {
|
|
11
|
+
* @Post('/')
|
|
12
|
+
* create(@BodyParams() body: any) {
|
|
13
|
+
* console.log('Entire body', body);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* @Post('/')
|
|
17
|
+
* create(@BodyParams('id') id: string) {
|
|
18
|
+
* console.log('ID', id);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* @Post('/')
|
|
22
|
+
* create(@BodyParams('user') user: User) { // with deserialization
|
|
23
|
+
* console.log('user', user);
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @Post('/')
|
|
27
|
+
* create(@BodyParams('users', User) users: User[]) { // with deserialization
|
|
28
|
+
* console.log('users', users);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
33
|
+
*
|
|
34
|
+
* @param expression The path of the property to get.
|
|
35
|
+
* @param useType The type of the class that to be used to deserialize the data.
|
|
36
|
+
* @decorator
|
|
37
|
+
* @operation
|
|
38
|
+
* @input
|
|
39
|
+
*/
|
|
40
|
+
export declare function BodyParams(expression: string, useType: Type<any>): ParameterDecorator;
|
|
41
|
+
export declare function BodyParams(expression: string): ParameterDecorator;
|
|
42
|
+
export declare function BodyParams(useType: Type<any>): ParameterDecorator;
|
|
43
|
+
export declare function BodyParams(options: Partial<ParamOptions>): ParameterDecorator;
|
|
44
|
+
export declare function BodyParams(): ParameterDecorator;
|
|
45
|
+
/**
|
|
46
|
+
* RawBodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) as a Buffer.
|
|
47
|
+
*
|
|
48
|
+
* #### Example
|
|
49
|
+
*
|
|
50
|
+
* ```typescript
|
|
51
|
+
* @Controller('/')
|
|
52
|
+
* class MyCtrl {
|
|
53
|
+
* @Post('/')
|
|
54
|
+
* create(@RawBodyParams() body: Buffer) {
|
|
55
|
+
* console.log('Entire body', body.toString("utf8"));
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @decorator
|
|
61
|
+
* @operation
|
|
62
|
+
* @input
|
|
63
|
+
*/
|
|
64
|
+
export declare function RawBodyParams(): ParameterDecorator;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseContext } from "@tsed/di";
|
|
2
|
+
declare global {
|
|
3
|
+
namespace TsED {
|
|
4
|
+
interface Context {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Context decorator return the @@PlatformContext@@ created by Ts.ED when request is handled by the server.
|
|
10
|
+
*
|
|
11
|
+
* It contains some information as following:
|
|
12
|
+
*
|
|
13
|
+
* - The request id,
|
|
14
|
+
* - The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`,
|
|
15
|
+
* - The current @@EndpointMetadata@@ resolved by Ts.ED during the request,
|
|
16
|
+
* - The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
17
|
+
*
|
|
18
|
+
* ::: tip
|
|
19
|
+
* The @@PlatformContext@@ inherit from Map class. So you can store any information with.
|
|
20
|
+
* :::
|
|
21
|
+
*
|
|
22
|
+
* #### Example
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* @Middleware()
|
|
26
|
+
* class AuthTokenMiddleware {
|
|
27
|
+
* use(@Req() request: Req, @Context() context: PlatformContext) {
|
|
28
|
+
* if (!context.has("auth")){
|
|
29
|
+
* context.set('auth', new AuthToken(request))
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* try {
|
|
33
|
+
* context.get("auth").claims() // check token
|
|
34
|
+
* } catch(er){
|
|
35
|
+
* throw new Forbidden("Access forbidden - Bad token")
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* @Controller('/')
|
|
41
|
+
* @UseBefore(AuthTokenMiddleware) // protect all routes for this controller
|
|
42
|
+
* class MyCtrl {
|
|
43
|
+
* @Get('/')
|
|
44
|
+
* get(@Context('auth') auth: AuthToken) {
|
|
45
|
+
* console.log('auth', auth);
|
|
46
|
+
* console.log('auth.accessToken', auth.accessToken);
|
|
47
|
+
* console.log('auth.idToken', auth.idToken);
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param expression The path of the property to get.
|
|
53
|
+
* @decorator
|
|
54
|
+
* @operation
|
|
55
|
+
* @input
|
|
56
|
+
*/
|
|
57
|
+
export declare function Context(expression: string): ParameterDecorator;
|
|
58
|
+
export declare function Context(): ParameterDecorator;
|
|
59
|
+
export declare type Context = BaseContext;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ParamOptions } from "../domain/ParamOptions";
|
|
3
|
+
/**
|
|
4
|
+
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
|
|
5
|
+
*
|
|
6
|
+
* #### Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller('/')
|
|
10
|
+
* class MyCtrl {
|
|
11
|
+
* @Post('/')
|
|
12
|
+
* create(@Cookies() cookies: any) {
|
|
13
|
+
* console.log('Entire cookies', cookies);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* @Post('/')
|
|
17
|
+
* create(@Cookies('id') id: string) {
|
|
18
|
+
* console.log('ID', id);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* @Post('/')
|
|
22
|
+
* create(@Cookies('user') user: IUser) {
|
|
23
|
+
* console.log('user', user);
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
28
|
+
*
|
|
29
|
+
* @param expression The path of the property to get.
|
|
30
|
+
* @param useType The type of the class that to be used to deserialize the data.
|
|
31
|
+
* @decorator
|
|
32
|
+
* @operation
|
|
33
|
+
* @input
|
|
34
|
+
*/
|
|
35
|
+
export declare function CookiesParams(expression: string | any, useType: any): ParameterDecorator;
|
|
36
|
+
export declare function CookiesParams(): ParameterDecorator;
|
|
37
|
+
export declare function CookiesParams(expression: string | any): ParameterDecorator;
|
|
38
|
+
export declare function CookiesParams(options: ParamOptions<any>): ParameterDecorator;
|
|
39
|
+
/**
|
|
40
|
+
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
|
|
41
|
+
*
|
|
42
|
+
* #### Example
|
|
43
|
+
*
|
|
44
|
+
* ```typescript
|
|
45
|
+
* @Controller('/')
|
|
46
|
+
* class MyCtrl {
|
|
47
|
+
* @Post('/')
|
|
48
|
+
* create(@Cookies() body: any) {
|
|
49
|
+
* console.log('Entire body', body);
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* @Post('/')
|
|
53
|
+
* create(@Cookies('id') id: string) {
|
|
54
|
+
* console.log('ID', id);
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* @Post('/')
|
|
58
|
+
* create(@Cookies('user') user: User) { // with deserialization
|
|
59
|
+
* console.log('user', user);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* @Post('/')
|
|
63
|
+
* create(@Cookies('users', User) users: User[]) { // with deserialization
|
|
64
|
+
* console.log('users', users);
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
* > For more information on deserialization see [converters](/docs/converters.md) page.
|
|
69
|
+
*
|
|
70
|
+
* @param expression The path of the property to get.
|
|
71
|
+
* @param useType The type of the class that to be used to deserialize the data.
|
|
72
|
+
* @decorator
|
|
73
|
+
* @aliasof CookiesParams
|
|
74
|
+
* @operation
|
|
75
|
+
* @input
|
|
76
|
+
*/
|
|
77
|
+
export declare function Cookies(expression: string, useType: Type<any>): ParameterDecorator;
|
|
78
|
+
export declare function Cookies(expression: string): ParameterDecorator;
|
|
79
|
+
export declare function Cookies(useType: Type<any>): ParameterDecorator;
|
|
80
|
+
export declare function Cookies(options: Partial<ParamOptions>): ParameterDecorator;
|
|
81
|
+
export declare function Cookies(): ParameterDecorator;
|