@tsed/platform-params 6.97.2 → 6.98.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/builder/PlatformParams.js.map +1 -1
- package/lib/cjs/decorators/paramFn.js +2 -7
- package/lib/cjs/decorators/paramFn.js.map +1 -1
- package/lib/cjs/decorators/usePipe.js.map +1 -1
- package/lib/cjs/domain/ParamMetadata.js +2 -30
- package/lib/cjs/domain/ParamMetadata.js.map +1 -1
- package/lib/cjs/errors/ParamValidationError.js.map +1 -1
- package/lib/cjs/errors/RequiredValidationError.js.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/pipes/DeserializerPipe.js.map +1 -1
- package/lib/cjs/pipes/ParseExpressionPipe.js +9 -1
- package/lib/cjs/pipes/ParseExpressionPipe.js.map +1 -1
- package/lib/cjs/pipes/ValidationPipe.js.map +1 -1
- package/lib/esm/builder/PlatformParams.js.map +1 -1
- package/lib/esm/decorators/paramFn.js +2 -7
- package/lib/esm/decorators/paramFn.js.map +1 -1
- package/lib/esm/decorators/usePipe.js.map +1 -1
- package/lib/esm/domain/ParamMetadata.js +1 -30
- package/lib/esm/domain/ParamMetadata.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/index.js.map +1 -1
- package/lib/esm/pipes/DeserializerPipe.js.map +1 -1
- package/lib/esm/pipes/ParseExpressionPipe.js +9 -1
- package/lib/esm/pipes/ParseExpressionPipe.js.map +1 -1
- package/lib/esm/pipes/ValidationPipe.js.map +1 -1
- package/lib/types/builder/PlatformParams.d.ts +3 -4
- package/lib/types/decorators/paramFn.d.ts +2 -2
- package/lib/types/decorators/usePipe.d.ts +1 -1
- package/lib/types/domain/ParamMetadata.d.ts +1 -16
- package/lib/types/errors/ParamValidationError.d.ts +2 -2
- package/lib/types/errors/RequiredValidationError.d.ts +2 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/pipes/DeserializerPipe.d.ts +2 -2
- package/lib/types/pipes/ParseExpressionPipe.d.ts +3 -2
- package/lib/types/pipes/ValidationPipe.d.ts +5 -5
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformParams.js","sourceRoot":"","sources":["../../../src/builder/PlatformParams.ts"],"names":[],"mappings":";;;;AAAA,iCAAsG;AACtG,
|
|
1
|
+
{"version":3,"file":"PlatformParams.js","sourceRoot":"","sources":["../../../src/builder/PlatformParams.ts"],"names":[],"mappings":";;;;AAAA,iCAAsG;AACtG,yCAA8E;AAC9E,yEAAoE;AACpE,sEAAiE;AAWjE;;;GAGG;AAKH,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,KAAK,CAAC,QAAQ,CAAC,KAAyB;QACtC,MAAM,GAAG,GAAG,CAAC,IAAmB,EAAE,EAAE;YAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAE,CAAC,QAAQ,IAAI,CAAC,CAAC;QACxD,CAAC,CAAC;QAEF,MAAM,IAAI,GAAG,CAAC,EAAiB,EAAE,EAAiB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5G,MAAM,GAAG,GAAG,CAAC,KAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAc,KAAK,CAAE,CAAC;QAChF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,yCAAmB,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,C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;IACJ,CAAC;CACF,CAAA;AA1EC;IADC,IAAA,WAAM,GAAE;2CACW,oBAAe;gDAAC;AAFzB,cAAc;IAJ1B,IAAA,eAAU,EAAC;QACV,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,cAAc,CA4E1B;AA5EY,wCAAc","sourcesContent":["import {DIContext, Inject, Injectable, InjectorService, ProviderScope, TokenProvider} from \"@tsed/di\";\nimport {JsonEntityStore, JsonParameterStore, PipeMethods} from \"@tsed/schema\";\nimport {ParamValidationError} from \"../errors/ParamValidationError\";\nimport {ParseExpressionPipe} from \"../pipes/ParseExpressionPipe\";\n\nexport type ArgScope<Context extends DIContext = DIContext> = {$ctx: Context} & Record<string, any>;\nexport type HandlerWithScope<Context extends DIContext = DIContext> = (scope: ArgScope<Context>) => any;\n\nexport interface CompileHandlerOptions<Context extends DIContext = DIContext> extends Record<any, unknown> {\n token: TokenProvider;\n propertyKey: string | symbol;\n getCustomArgs?: (scope: ArgScope<Context>) => Promise<any[]>;\n}\n\n/**\n * Platform Params abstraction layer.\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: []\n})\nexport class PlatformParams {\n @Inject()\n protected injector: InjectorService;\n\n async getPipes(param: JsonParameterStore) {\n const get = (pipe: TokenProvider) => {\n return this.injector.getProvider(pipe)!.priority || 0;\n };\n\n const sort = (p1: TokenProvider, p2: TokenProvider) => (get(p1) < get(p2) ? -1 : get(p1) > get(p2) ? 1 : 0);\n const map = (token: TokenProvider) => this.injector.invoke<PipeMethods>(token)!;\n const promises = await Promise.all([ParseExpressionPipe, ...param.pipes.sort(sort)].map(map));\n\n return promises.filter(Boolean);\n }\n\n async compile<Context extends DIContext = DIContext>(entity: JsonEntityStore) {\n const params = JsonParameterStore.getParams(entity.target, entity.propertyKey);\n\n const argsPipes = await Promise.all(\n params.map(async (param) => {\n return {\n param,\n pipes: await this.getPipes(param)\n };\n })\n );\n\n return (scope: ArgScope<Context>) => {\n const promises = argsPipes.map(({param, pipes}) => {\n return this.getArg(scope, pipes, param);\n });\n\n return Promise.all(promises);\n };\n }\n\n async getArg(scope: ArgScope, pipes: PipeMethods[], param: JsonParameterStore) {\n return pipes.reduce(async (value, pipe) => {\n value = await value;\n\n try {\n return await pipe.transform(value, param);\n } catch (er) {\n throw ParamValidationError.from(param, er);\n }\n }, scope as any);\n }\n\n async compileHandler<Context extends DIContext = DIContext>(\n metadata: CompileHandlerOptions<Context>\n ): Promise<HandlerWithScope<Context>> {\n const {token, propertyKey, getCustomArgs} = metadata;\n\n const provider = this.injector.getProvider(token);\n const getArguments = getCustomArgs || (await this.compile<Context>(JsonEntityStore.fromMethod(token, propertyKey!)));\n\n if (!provider || !provider.scope || provider.scope === ProviderScope.SINGLETON) {\n const instance = await this.injector.invoke<any>(token);\n const handler = instance[propertyKey!].bind(instance);\n\n return async (scope) => {\n const args = await getArguments(scope);\n\n return handler(...args, scope.$ctx);\n };\n }\n\n return async (scope) => {\n const [instance, args] = await Promise.all([this.injector.invoke<any>(token, scope.$ctx.container), getArguments(scope)]);\n\n const handler = instance[propertyKey!].bind(instance);\n\n return handler(...args, scope.$ctx);\n };\n }\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParamFn = void 0;
|
|
4
|
-
const
|
|
5
|
-
const ParamMetadata_1 = require("../domain/ParamMetadata");
|
|
4
|
+
const schema_1 = require("@tsed/schema");
|
|
6
5
|
/**
|
|
7
6
|
* Get the Param metadata. Use this decorator to compose your own decorator.
|
|
8
7
|
*
|
|
@@ -12,11 +11,7 @@ const ParamMetadata_1 = require("../domain/ParamMetadata");
|
|
|
12
11
|
* @input
|
|
13
12
|
*/
|
|
14
13
|
function ParamFn(fn) {
|
|
15
|
-
return (
|
|
16
|
-
if ((0, core_1.decoratorTypeOf)([target, propertyKey, index]) === core_1.DecoratorTypes.PARAM) {
|
|
17
|
-
fn(ParamMetadata_1.ParamMetadata.get(target, propertyKey, index), [target, propertyKey, index]);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
14
|
+
return (0, schema_1.JsonEntityFn)(fn);
|
|
20
15
|
}
|
|
21
16
|
exports.ParamFn = ParamFn;
|
|
22
17
|
//# sourceMappingURL=paramFn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paramFn.js","sourceRoot":"","sources":["../../../src/decorators/paramFn.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"paramFn.js","sourceRoot":"","sources":["../../../src/decorators/paramFn.ts"],"names":[],"mappings":";;;AACA,yCAA8D;AAE9D;;;;;;;GAOG;AACH,SAAgB,OAAO,CAAC,EAAwE;IAC9F,OAAO,IAAA,qBAAY,EAAqB,EAAE,CAAC,CAAC;AAC9C,CAAC;AAFD,0BAEC","sourcesContent":["import {DecoratorParameters} from \"@tsed/core\";\nimport {JsonEntityFn, JsonParameterStore} from \"@tsed/schema\";\n\n/**\n * Get the Param metadata. Use this decorator to compose your own decorator.\n *\n * @param fn\n * @decorator\n * @operation\n * @input\n */\nexport function ParamFn(fn: (param: JsonParameterStore, parameters: DecoratorParameters) => void): ParameterDecorator {\n return JsonEntityFn<JsonParameterStore>(fn);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePipe.js","sourceRoot":"","sources":["../../../src/decorators/usePipe.ts"],"names":[],"mappings":";;;AAEA,uCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAgB,OAAO,CAAC,KAAwB,EAAE,UAAe,EAAE;IACjE,OAAO,IAAA,iBAAO,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","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PipeMethods} from \"
|
|
1
|
+
{"version":3,"file":"usePipe.js","sourceRoot":"","sources":["../../../src/decorators/usePipe.ts"],"names":[],"mappings":";;;AAEA,uCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAgB,OAAO,CAAC,KAAwB,EAAE,UAAe,EAAE;IACjE,OAAO,IAAA,iBAAO,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","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,34 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParamMetadata = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const schema_1 = require("@tsed/schema");
|
|
7
|
-
const ParamTypes_1 = require("./ParamTypes");
|
|
8
|
-
let ParamMetadata = class ParamMetadata extends schema_1.JsonParameterStore {
|
|
9
|
-
constructor(options) {
|
|
10
|
-
super(options);
|
|
11
|
-
this.paramType = "$ctx";
|
|
12
|
-
this.pipes = [];
|
|
13
|
-
this.paramType = options.paramType || this.paramType;
|
|
14
|
-
this.expression = options.expression || this.expression;
|
|
15
|
-
this.dataPath = options.dataPath || this.dataPath;
|
|
16
|
-
this.pipes = options.pipes || [];
|
|
17
|
-
}
|
|
18
|
-
get key() {
|
|
19
|
-
let { expression, paramType, dataPath } = this;
|
|
20
|
-
if (expression && paramType === ParamTypes_1.ParamTypes.HEADER) {
|
|
21
|
-
expression = String(expression).toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
return [dataPath, expression].filter(Boolean).join(".");
|
|
24
|
-
}
|
|
25
|
-
static get(target, propertyKey, index) {
|
|
26
|
-
return schema_1.JsonEntityStore.from((0, core_1.prototypeOf)(target), propertyKey, index);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
ParamMetadata = (0, tslib_1.__decorate)([
|
|
30
|
-
(0, schema_1.JsonEntityComponent)(core_1.DecoratorTypes.PARAM),
|
|
31
|
-
(0, tslib_1.__metadata)("design:paramtypes", [Object])
|
|
32
|
-
], ParamMetadata);
|
|
33
|
-
exports.ParamMetadata = ParamMetadata;
|
|
4
|
+
var schema_1 = require("@tsed/schema");
|
|
5
|
+
Object.defineProperty(exports, "ParamMetadata", { enumerable: true, get: function () { return schema_1.ParamMetadata; } });
|
|
34
6
|
//# sourceMappingURL=ParamMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParamMetadata.js","sourceRoot":"","sources":["../../../src/domain/ParamMetadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ParamMetadata.js","sourceRoot":"","sources":["../../../src/domain/ParamMetadata.ts"],"names":[],"mappings":";;;AAAA,uCAA2C;AAAnC,uGAAA,aAAa,OAAA","sourcesContent":["export {ParamMetadata} from \"@tsed/schema\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParamValidationError.js","sourceRoot":"","sources":["../../../src/errors/ParamValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,iDAA4C;AAE5C,uDAAkD;AAElD,MAAa,oBAAqB,SAAQ,uBAAU;IAApD;;QACS,SAAI,GAAW,wBAAwB,CAAC;IAsBjD,CAAC;IAlBC,MAAM,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"ParamValidationError.js","sourceRoot":"","sources":["../../../src/errors/ParamValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,iDAA4C;AAE5C,uDAAkD;AAElD,MAAa,oBAAqB,SAAQ,uBAAU;IAApD;;QACS,SAAI,GAAW,wBAAwB,CAAC;IAsBjD,CAAC;IAlBC,MAAM,CAAC,IAAI,CAAC,QAA4B,EAAE,SAAc,EAAE;QACxD,IAAI,MAAM,YAAY,iCAAe,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,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,IAAA,aAAM,EAAC,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;AAvBD,oDAuBC","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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequiredValidationError.js","sourceRoot":"","sources":["../../../src/errors/RequiredValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;
|
|
1
|
+
{"version":3,"file":"RequiredValidationError.js","sourceRoot":"","sources":["../../../src/errors/RequiredValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,uDAAkD;AAGlD,MAAa,uBAAwB,SAAQ,iCAAe;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","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"]}
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAEA,wEAAyC;AAEzC,SAAS;AACT,sEAAuC;AACvC,qEAAsC;AACtC,mEAAoC;AAEpC,QAAQ;AACR,2EAA4C;AAC5C,wEAAyC;AACzC,sEAAuC;AAEvC,UAAU;AACV,wEAAyC;AAEzC,SAAS;AACT,gFAAiD;AACjD,wEAAyC;AACzC,6EAA8C;AAE9C,aAAa;AACb,oEAAqC;AACrC,uEAAwC;AACxC,oEAAqC;AACrC,qEAAsC;AACtC,yEAA0C;AAC1C,oEAAqC;AACrC,0EAA2C;AAC3C,+EAAgD;AAChD,+EAAgD;AAChD,yEAA0C;AAC1C,yEAA0C;AAC1C,oEAAqC;AACrC,mEAAoC;AACpC,uEAAwC;AACxC,wEAAyC;AACzC,oEAAqC;AACrC,oEAAqC","sourcesContent":["export {PipeMethods} from \"@tsed/schema\";\n\nexport * 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeserializerPipe.js","sourceRoot":"","sources":["../../../src/pipes/DeserializerPipe.ts"],"names":[],"mappings":";;;;;AAAA,iCAA8C;AAC9C,mDAA8C;AAI9C,IAAa,gBAAgB,wBAA7B,MAAa,gBAAgB;IAM3B,SAAS,CAAC,KAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"DeserializerPipe.js","sourceRoot":"","sources":["../../../src/pipes/DeserializerPipe.ts"],"names":[],"mappings":";;;;;AAAA,iCAA8C;AAC9C,mDAA8C;AAI9C,IAAa,gBAAgB,wBAA7B,MAAa,gBAAgB;IAM3B,SAAS,CAAC,KAAU,EAAE,KAAyB;QAC7C,OAAO,IAAA,yBAAW,EAAC,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,IAAA,aAAQ,EAAC,WAAW,EAAE,EAAE,CAAC;;kDAGxB;AAJS,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAkB5B;AAlBY,4CAAgB","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"]}
|
|
@@ -8,12 +8,20 @@ const ParamTypes_1 = require("../domain/ParamTypes");
|
|
|
8
8
|
let ParseExpressionPipe = class ParseExpressionPipe {
|
|
9
9
|
transform(scope, param) {
|
|
10
10
|
const { paramType, type } = param;
|
|
11
|
-
const value = (0, core_1.getValue)(scope, param
|
|
11
|
+
const value = (0, core_1.getValue)(scope, this.getKey(param));
|
|
12
12
|
if ([ParamTypes_1.ParamTypes.QUERY, ParamTypes_1.ParamTypes.PATH].includes(paramType) && value === "" && type !== String) {
|
|
13
13
|
return undefined;
|
|
14
14
|
}
|
|
15
15
|
return value;
|
|
16
16
|
}
|
|
17
|
+
getKey(param) {
|
|
18
|
+
let { expression, paramType, dataPath } = param;
|
|
19
|
+
paramType = paramType || param.parameter.get("in").toUpperCase();
|
|
20
|
+
if (expression && paramType === ParamTypes_1.ParamTypes.HEADER) {
|
|
21
|
+
expression = String(expression).toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
return [dataPath, expression].filter(Boolean).join(".");
|
|
24
|
+
}
|
|
17
25
|
};
|
|
18
26
|
ParseExpressionPipe = (0, tslib_1.__decorate)([
|
|
19
27
|
(0, di_1.Injectable)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseExpressionPipe.js","sourceRoot":"","sources":["../../../src/pipes/ParseExpressionPipe.ts"],"names":[],"mappings":";;;;AAAA,qCAAoC;AACpC,iCAAoC;AAEpC,qDAAgD;AAMhD,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAC9B,SAAS,CAAC,KAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"ParseExpressionPipe.js","sourceRoot":"","sources":["../../../src/pipes/ParseExpressionPipe.ts"],"names":[],"mappings":";;;;AAAA,qCAAoC;AACpC,iCAAoC;AAEpC,qDAAgD;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,IAAA,eAAQ,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,IAAI,CAAC,uBAAU,CAAC,KAAK,EAAE,uBAAU,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,uBAAU,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","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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.ts"],"names":[],"mappings":";;;;AAAA,qCAAkC;AAClC,iCAAqD;AACrD,mDAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.ts"],"names":[],"mappings":";;;;AAAA,qCAAkC;AAClC,iCAAqD;AACrD,mDAA8C;AAC9C,yCAA4E;AAC5E,+EAA0E;AAC1E,qDAAgD;AAEhD,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;AAKD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAGzB,YAAY,QAAyB;QACnC,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAA,aAAM,EAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,CAAC;QAErG,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;SACvD;IACH,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,QAA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Q,CAAC,CAAC;SAC9C;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzEY,cAAc;IAH1B,IAAA,eAAU,EAAC;QACV,IAAI,EAAE,WAAW;KAClB,CAAC;kDAIsB,oBAAe;GAH1B,cAAc,CAyE1B;AAzEY,wCAAc","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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformParams.js","sourceRoot":"","sources":["../../../src/builder/PlatformParams.ts"],"names":[],"mappings":";AAAA,OAAO,EAAY,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AACtG,OAAO,EAAC,eAAe,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"PlatformParams.js","sourceRoot":"","sources":["../../../src/builder/PlatformParams.ts"],"names":[],"mappings":";AAAA,OAAO,EAAY,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AACtG,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAWjE;;;GAGG;AAKH,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,KAAK,CAAC,QAAQ,CAAC,KAAyB;QACtC,MAAM,GAAG,GAAG,CAAC,IAAmB,EAAE,EAAE;YAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAE,CAAC,QAAQ,IAAI,CAAC,CAAC;QACxD,CAAC,CAAC;QAEF,MAAM,IAAI,GAAG,CAAC,EAAiB,EAAE,EAAiB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CA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MAAM,CAAM,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAE1H,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAY,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEtD,OAAO,OAAO,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AA1EC;IADC,MAAM,EAAE;8BACW,eAAe;gDAAC;AAFzB,cAAc;IAJ1B,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,cAAc,CA4E1B;SA5EY,cAAc","sourcesContent":["import {DIContext, Inject, Injectable, InjectorService, ProviderScope, TokenProvider} from \"@tsed/di\";\nimport {JsonEntityStore, JsonParameterStore, PipeMethods} from \"@tsed/schema\";\nimport {ParamValidationError} from \"../errors/ParamValidationError\";\nimport {ParseExpressionPipe} from \"../pipes/ParseExpressionPipe\";\n\nexport type ArgScope<Context extends DIContext = DIContext> = {$ctx: Context} & Record<string, any>;\nexport type HandlerWithScope<Context extends DIContext = DIContext> = (scope: ArgScope<Context>) => any;\n\nexport interface CompileHandlerOptions<Context extends DIContext = DIContext> extends Record<any, unknown> {\n token: TokenProvider;\n propertyKey: string | symbol;\n getCustomArgs?: (scope: ArgScope<Context>) => Promise<any[]>;\n}\n\n/**\n * Platform Params abstraction layer.\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: []\n})\nexport class PlatformParams {\n @Inject()\n protected injector: InjectorService;\n\n async getPipes(param: JsonParameterStore) {\n const get = (pipe: TokenProvider) => {\n return this.injector.getProvider(pipe)!.priority || 0;\n };\n\n const sort = (p1: TokenProvider, p2: TokenProvider) => (get(p1) < get(p2) ? -1 : get(p1) > get(p2) ? 1 : 0);\n const map = (token: TokenProvider) => this.injector.invoke<PipeMethods>(token)!;\n const promises = await Promise.all([ParseExpressionPipe, ...param.pipes.sort(sort)].map(map));\n\n return promises.filter(Boolean);\n }\n\n async compile<Context extends DIContext = DIContext>(entity: JsonEntityStore) {\n const params = JsonParameterStore.getParams(entity.target, entity.propertyKey);\n\n const argsPipes = await Promise.all(\n params.map(async (param) => {\n return {\n param,\n pipes: await this.getPipes(param)\n };\n })\n );\n\n return (scope: ArgScope<Context>) => {\n const promises = argsPipes.map(({param, pipes}) => {\n return this.getArg(scope, pipes, param);\n });\n\n return Promise.all(promises);\n };\n }\n\n async getArg(scope: ArgScope, pipes: PipeMethods[], param: JsonParameterStore) {\n return pipes.reduce(async (value, pipe) => {\n value = await value;\n\n try {\n return await pipe.transform(value, param);\n } catch (er) {\n throw ParamValidationError.from(param, er);\n }\n }, scope as any);\n }\n\n async compileHandler<Context extends DIContext = DIContext>(\n metadata: CompileHandlerOptions<Context>\n ): Promise<HandlerWithScope<Context>> {\n const {token, propertyKey, getCustomArgs} = metadata;\n\n const provider = this.injector.getProvider(token);\n const getArguments = getCustomArgs || (await this.compile<Context>(JsonEntityStore.fromMethod(token, propertyKey!)));\n\n if (!provider || !provider.scope || provider.scope === ProviderScope.SINGLETON) {\n const instance = await this.injector.invoke<any>(token);\n const handler = instance[propertyKey!].bind(instance);\n\n return async (scope) => {\n const args = await getArguments(scope);\n\n return handler(...args, scope.$ctx);\n };\n }\n\n return async (scope) => {\n const [instance, args] = await Promise.all([this.injector.invoke<any>(token, scope.$ctx.container), getArguments(scope)]);\n\n const handler = instance[propertyKey!].bind(instance);\n\n return handler(...args, scope.$ctx);\n };\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ParamMetadata } from "../domain/ParamMetadata";
|
|
1
|
+
import { JsonEntityFn } from "@tsed/schema";
|
|
3
2
|
/**
|
|
4
3
|
* Get the Param metadata. Use this decorator to compose your own decorator.
|
|
5
4
|
*
|
|
@@ -9,10 +8,6 @@ import { ParamMetadata } from "../domain/ParamMetadata";
|
|
|
9
8
|
* @input
|
|
10
9
|
*/
|
|
11
10
|
export function ParamFn(fn) {
|
|
12
|
-
return (
|
|
13
|
-
if (decoratorTypeOf([target, propertyKey, index]) === DecoratorTypes.PARAM) {
|
|
14
|
-
fn(ParamMetadata.get(target, propertyKey, index), [target, propertyKey, index]);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
11
|
+
return JsonEntityFn(fn);
|
|
17
12
|
}
|
|
18
13
|
//# sourceMappingURL=paramFn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paramFn.js","sourceRoot":"","sources":["../../../src/decorators/paramFn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paramFn.js","sourceRoot":"","sources":["../../../src/decorators/paramFn.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAqB,MAAM,cAAc,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC,EAAwE;IAC9F,OAAO,YAAY,CAAqB,EAAE,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import {DecoratorParameters} from \"@tsed/core\";\nimport {JsonEntityFn, JsonParameterStore} from \"@tsed/schema\";\n\n/**\n * Get the Param metadata. Use this decorator to compose your own decorator.\n *\n * @param fn\n * @decorator\n * @operation\n * @input\n */\nexport function ParamFn(fn: (param: JsonParameterStore, parameters: DecoratorParameters) => void): ParameterDecorator {\n return JsonEntityFn<JsonParameterStore>(fn);\n}\n"]}
|
|
@@ -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 \"
|
|
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,31 +1,2 @@
|
|
|
1
|
-
|
|
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":"
|
|
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"]}
|
|
@@ -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,OAA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AO,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequiredValidationError.js","sourceRoot":"","sources":["../../../src/errors/RequiredValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;
|
|
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"]}
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,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 {PipeMethods} from \"@tsed/schema\";\n\nexport * 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 +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,
|
|
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"]}
|
|
@@ -5,12 +5,20 @@ import { ParamTypes } from "../domain/ParamTypes";
|
|
|
5
5
|
let ParseExpressionPipe = class ParseExpressionPipe {
|
|
6
6
|
transform(scope, param) {
|
|
7
7
|
const { paramType, type } = param;
|
|
8
|
-
const value = getValue(scope, param
|
|
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"],"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C,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.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AzEY,cAAc;IAH1B,UAAU,CAAC;QACV,IAAI,EAAE,WAAW;KAClB,CAAC;qCAIsB,eAAe;GAH1B,cAAc,CAyE1B;SAzEY,cAAc","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:
|
|
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:
|
|
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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DecoratorParameters } from "@tsed/core";
|
|
2
|
-
import {
|
|
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:
|
|
11
|
+
export declare function ParamFn(fn: (param: JsonParameterStore, parameters: DecoratorParameters) => void): ParameterDecorator;
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
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";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BadRequest } from "@tsed/exceptions";
|
|
2
|
-
import {
|
|
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:
|
|
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:
|
|
5
|
+
static from(metadata: JsonParameterStore): RequiredValidationError;
|
|
6
6
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonParameterStore, PipeMethods } from "@tsed/schema";
|
|
2
2
|
export declare class DeserializerPipe implements PipeMethods {
|
|
3
3
|
private settings;
|
|
4
|
-
transform(value: any, param:
|
|
4
|
+
transform(value: any, param: JsonParameterStore): any;
|
|
5
5
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonParameterStore, PipeMethods } from "@tsed/schema";
|
|
2
2
|
import type { ArgScope } from "../builder/PlatformParams";
|
|
3
3
|
export declare class ParseExpressionPipe implements PipeMethods {
|
|
4
|
-
transform(scope: ArgScope, param:
|
|
4
|
+
transform(scope: ArgScope, param: JsonParameterStore): any;
|
|
5
|
+
protected getKey(param: JsonParameterStore): string;
|
|
5
6
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { InjectorService } from "@tsed/di";
|
|
2
|
-
import {
|
|
2
|
+
import { JsonParameterStore, PipeMethods } from "@tsed/schema";
|
|
3
3
|
export declare class ValidationPipe implements PipeMethods {
|
|
4
4
|
private validator;
|
|
5
5
|
constructor(injector: InjectorService);
|
|
6
|
-
coerceTypes(value: any, metadata:
|
|
7
|
-
skip(value: any, metadata:
|
|
8
|
-
transform(value: any, metadata:
|
|
9
|
-
protected checkIsRequired(value: any, metadata:
|
|
6
|
+
coerceTypes(value: any, metadata: JsonParameterStore): any;
|
|
7
|
+
skip(value: any, metadata: JsonParameterStore): boolean;
|
|
8
|
+
transform(value: any, metadata: JsonParameterStore): Promise<any>;
|
|
9
|
+
protected checkIsRequired(value: any, metadata: JsonParameterStore): boolean;
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-params",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.98.3",
|
|
4
4
|
"description": "Params module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"tslib": "2.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tsed/core": "6.
|
|
25
|
-
"@tsed/di": "6.
|
|
26
|
-
"@tsed/exceptions": "6.
|
|
27
|
-
"@tsed/json-mapper": "6.
|
|
28
|
-
"@tsed/schema": "6.
|
|
24
|
+
"@tsed/core": "6.98.3",
|
|
25
|
+
"@tsed/di": "6.98.3",
|
|
26
|
+
"@tsed/exceptions": "6.98.3",
|
|
27
|
+
"@tsed/json-mapper": "6.98.3",
|
|
28
|
+
"@tsed/schema": "6.98.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tsed/core": "^6.
|
|
32
|
-
"@tsed/di": "^6.
|
|
33
|
-
"@tsed/exceptions": "^6.
|
|
34
|
-
"@tsed/json-mapper": "^6.
|
|
35
|
-
"@tsed/schema": "^6.
|
|
31
|
+
"@tsed/core": "^6.98.3",
|
|
32
|
+
"@tsed/di": "^6.98.3",
|
|
33
|
+
"@tsed/exceptions": "^6.98.3",
|
|
34
|
+
"@tsed/json-mapper": "^6.98.3",
|
|
35
|
+
"@tsed/schema": "^6.98.3"
|
|
36
36
|
},
|
|
37
37
|
"repository": "https://github.com/tsedio/tsed",
|
|
38
38
|
"bugs": {
|