@nestia/core 1.1.0-dev.20230413 → 1.1.0-dev.20230420
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/decorators/EncryptedModule.d.ts +3 -3
- package/lib/decorators/EncryptedModule.js.map +1 -1
- package/lib/decorators/EncryptedRoute.js +3 -3
- package/lib/decorators/EncryptedRoute.js.map +1 -1
- package/lib/decorators/TypedParam.d.ts +14 -8
- package/lib/decorators/TypedParam.js +13 -9
- package/lib/decorators/TypedParam.js.map +1 -1
- package/lib/decorators/TypedRoute.js +2 -2
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/decorators/internal/route_error.d.ts +1 -2
- package/lib/decorators/internal/route_error.js.map +1 -1
- package/lib/programmers/TypedBodyProgrammer.js +4 -4
- package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedParamProgrammer.d.ts +5 -0
- package/lib/programmers/TypedParamProgrammer.js +108 -0
- package/lib/programmers/TypedParamProgrammer.js.map +1 -0
- package/lib/programmers/TypedQueryProgrammer.js +5 -5
- package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
- package/lib/programmers/TypedRouteProgrammer.js +5 -5
- package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
- package/lib/transformers/ParameterDecoratorTransformer.js +20 -8
- package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
- package/package.json +18 -17
- package/src/decorators/EncryptedModule.ts +3 -3
- package/src/decorators/EncryptedRoute.ts +2 -5
- package/src/decorators/TypedParam.ts +15 -9
- package/src/decorators/TypedRoute.ts +2 -5
- package/src/decorators/internal/route_error.ts +2 -5
- package/src/programmers/TypedBodyProgrammer.ts +12 -14
- package/src/programmers/TypedParamProgrammer.ts +96 -0
- package/src/programmers/TypedQueryProgrammer.ts +11 -20
- package/src/programmers/TypedRouteProgrammer.ts +9 -14
- package/src/transformers/ParameterDecoratorTransformer.ts +26 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
|
|
2
|
-
import {
|
|
2
|
+
import { Module } from "@nestjs/common";
|
|
3
3
|
/**
|
|
4
4
|
* Encrypted module.
|
|
5
5
|
*
|
|
@@ -30,7 +30,7 @@ import { ModuleMetadata } from "@nestjs/common";
|
|
|
30
30
|
*
|
|
31
31
|
* @author Jeongho Nam - https://github.com/samchon
|
|
32
32
|
*/
|
|
33
|
-
export declare function EncryptedModule(metadata:
|
|
33
|
+
export declare function EncryptedModule(metadata: Parameters<typeof Module>[0], password: IEncryptionPassword | IEncryptionPassword.Closure): ClassDecorator;
|
|
34
34
|
export declare namespace EncryptedModule {
|
|
35
35
|
/**
|
|
36
36
|
* Dynamic encrypted module.
|
|
@@ -45,5 +45,5 @@ export declare namespace EncryptedModule {
|
|
|
45
45
|
* @param options Additional options except controller
|
|
46
46
|
* @returns Class decorated module instance
|
|
47
47
|
*/
|
|
48
|
-
function dynamic(path: string, password: IEncryptionPassword | IEncryptionPassword.Closure, options?: Omit<
|
|
48
|
+
function dynamic(path: string, password: IEncryptionPassword | IEncryptionPassword.Closure, options?: Omit<Parameters<typeof Module>[0], "controllers">): Promise<object>;
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedModule.js","sourceRoot":"","sources":["../../src/decorators/EncryptedModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"EncryptedModule.js","sourceRoot":"","sources":["../../src/decorators/EncryptedModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAwC;AAGxC,kEAAuE;AACvE,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,eAAe,CAC3B,QAAsC,EACtC,QAA2D;IAE3D,OAAO,UAAU,MAAW;;QACxB,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS;YAAE,OAAO;;YAE/C,KAAgB,IAAA,KAAA,SAAA,QAAQ,CAAC,WAAW,CAAA,gBAAA;gBAA/B,IAAM,CAAC,WAAA;gBACR,IAAI,OAAO,CAAC,WAAW,CAAC,2CAAuB,EAAE,CAAC,CAAC,KAAK,KAAK;oBACzD,OAAO,CAAC,cAAc,CAAC,2CAAuB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;aAAA;;;;;;;;;IACzE,CAAC,CAAC;AACN,CAAC;AAZD,0CAYC;AAED,WAAiB,eAAe;IAC5B;;;;;;;;;;;;OAYG;IACH,SAAsB,OAAO,CACzB,IAAY,EACZ,QAA2D,EAC3D,OAA+D;QAA/D,wBAAA,EAAA,YAA+D;;;;;4BAGxB,qBAAM,IAAA,kCAAgB,EAAC,IAAI,CAAC,EAAA;;wBAA7D,WAAW,GAAsB,SAA4B;;4BAInE;4BAAoB,CAAC;4BAAf,YAAY;gCADjB,eAAe,uBAAM,OAAO,KAAE,WAAW,aAAA,KAAI,QAAQ,CAAC;+BACjD,YAAY,CAAG;4BAAD,mBAAC;yBAAA,AAArB;wBACA,sBAAO,YAAY,EAAC;;;;KACvB;IAZqB,uBAAO,UAY5B,CAAA;AACL,CAAC,EA3BgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA2B/B"}
|
|
@@ -40,7 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.EncryptedRoute = void 0;
|
|
41
41
|
var fetcher_1 = require("@nestia/fetcher");
|
|
42
42
|
var common_1 = require("@nestjs/common");
|
|
43
|
-
var
|
|
43
|
+
var operators_1 = require("rxjs/operators");
|
|
44
44
|
var typia_1 = require("typia");
|
|
45
45
|
var Singleton_1 = require("../utils/Singleton");
|
|
46
46
|
var EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
@@ -176,7 +176,7 @@ var EncryptedRouteInterceptor = /** @class */ (function () {
|
|
|
176
176
|
EncryptedRouteInterceptor.prototype.intercept = function (context, next) {
|
|
177
177
|
var _this = this;
|
|
178
178
|
var http = context.switchToHttp();
|
|
179
|
-
return next.handle().pipe((0,
|
|
179
|
+
return next.handle().pipe((0, operators_1.map)(function (value) {
|
|
180
180
|
var param = Reflect.getMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, context.getClass());
|
|
181
181
|
if (!param)
|
|
182
182
|
throw (0, TransformError_1.TransformError)("EncryptedRoute.".concat(_this.method));
|
|
@@ -200,7 +200,7 @@ var EncryptedRouteInterceptor = /** @class */ (function () {
|
|
|
200
200
|
else if (body === undefined)
|
|
201
201
|
return body;
|
|
202
202
|
return fetcher_1.AesPkcs5.encrypt(body, password.key, password.iv);
|
|
203
|
-
}), (0,
|
|
203
|
+
}), (0, operators_1.catchError)(function (err) { return (0, route_error_1.route_error)(http.getRequest(), err); }));
|
|
204
204
|
};
|
|
205
205
|
return EncryptedRouteInterceptor;
|
|
206
206
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedRoute.js","sourceRoot":"","sources":["../../src/decorators/EncryptedRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,yCAWwB;AAGxB,
|
|
1
|
+
{"version":3,"file":"EncryptedRoute.js","sourceRoot":"","sources":["../../src/decorators/EncryptedRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,yCAWwB;AAGxB,4CAAiD;AAEjD,+BAKe;AAGf,gDAA+C;AAC/C,kEAAuE;AACvE,4DAA2D;AAC3D,4EAA2E;AAC3E,kEAAiE;AACjE,sDAAqD;AAErD;;;;;;;;;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AAK,CAAC;YAChB,IAAM,QAAQ,GACV,QAAQ,CAAC,QAAQ,KAAK,SAAS;gBAC3B,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,OAAO,QAAQ,CAAC,QAAQ,KAAK,UAAU;oBACzC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CACb,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,MAAA,EAAE,EAChC,KAAK,CACR;oBACH,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAE5B,IAAM,QAAQ,GAAqB,IAAI,CAAC,WAAW,EAAE,CAAC;YACtD,QAAQ,CAAC,MAAM,CACX,cAAc,EACd,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,YAAY,CAC/C,CAAC;YAEF,IAAI,QAAQ,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC;iBAC9B,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YACzC,OAAO,kBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,EACF,IAAA,sBAAU,EAAC,UAAC,GAAG,IAAK,OAAA,IAAA,yBAAW,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,EAAnC,CAAmC,CAAC,CAC3D,CAAC;IACN,CAAC;IACL,gCAAC;AAAD,CAAC,AArDD,IAqDC;AAED;;GAEG;AACH,IAAM,OAAO,GAAG;IACZ,GAAG,cAAA;IACH,IAAI,eAAA;IACJ,GAAG,cAAA;IACH,KAAK,gBAAA;IACL,MAAM,iBAAA;CACT,CAAC"}
|
|
@@ -3,23 +3,29 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `TypedParam` is a decorator function getting specific typed parameter from the
|
|
5
5
|
* HTTP request URL. It's almost same with the {@link nest.Param}, but `TypedParam`
|
|
6
|
-
*
|
|
7
|
-
* parses all of the parameters as string type.
|
|
6
|
+
* automatically casts parameter value to be following its type. Beside, the
|
|
7
|
+
* {@link nest.Param} always parses all of the parameters as `string` type.
|
|
8
|
+
*
|
|
9
|
+
* Note that, if you just omit the `type` and `nullable` parameters, then
|
|
10
|
+
* `TypedParam` automatically determines the `type` and `nullable` values
|
|
11
|
+
* just by analyzing the parameter type. Only when you need to specify them
|
|
12
|
+
* are, you want to use the `uuid` type.
|
|
8
13
|
*
|
|
9
14
|
* ```typescript
|
|
10
|
-
* \@TypedRoute.Get("shopping/sales/:
|
|
15
|
+
* \@TypedRoute.Get("shopping/sales/:id/:no/:paused")
|
|
11
16
|
* public async pause
|
|
12
17
|
* (
|
|
13
|
-
* \@TypedParam("
|
|
14
|
-
* \@TypedParam("
|
|
15
|
-
* \@TypedParam("paused"
|
|
18
|
+
* \@TypedParam("id", "uuid"), id: string, // uuid specification
|
|
19
|
+
* \@TypedParam("no") id: number, // auto casting
|
|
20
|
+
* \@TypedParam("paused") paused: boolean | null // auto casting
|
|
16
21
|
* ): Promise<void>;
|
|
17
22
|
* ```
|
|
18
23
|
*
|
|
19
24
|
* @param name URL Parameter name
|
|
20
|
-
* @param type
|
|
25
|
+
* @param type If omit, automatically determined by the parameter type.
|
|
26
|
+
* @param nullable If omit, automatically determined by the parameter type.
|
|
21
27
|
* @returns Parameter decorator
|
|
22
28
|
*
|
|
23
29
|
* @author Jeongho Nam - https://github.com/samchon
|
|
24
30
|
*/
|
|
25
|
-
export declare function TypedParam(name: string, type?: "boolean" | "number" | "string" | "uuid", nullable?:
|
|
31
|
+
export declare function TypedParam(name: string, type?: "boolean" | "number" | "string" | "uuid", nullable?: false | true): ParameterDecorator;
|
|
@@ -7,28 +7,32 @@ var common_1 = require("@nestjs/common");
|
|
|
7
7
|
*
|
|
8
8
|
* `TypedParam` is a decorator function getting specific typed parameter from the
|
|
9
9
|
* HTTP request URL. It's almost same with the {@link nest.Param}, but `TypedParam`
|
|
10
|
-
*
|
|
11
|
-
* parses all of the parameters as string type.
|
|
10
|
+
* automatically casts parameter value to be following its type. Beside, the
|
|
11
|
+
* {@link nest.Param} always parses all of the parameters as `string` type.
|
|
12
|
+
*
|
|
13
|
+
* Note that, if you just omit the `type` and `nullable` parameters, then
|
|
14
|
+
* `TypedParam` automatically determines the `type` and `nullable` values
|
|
15
|
+
* just by analyzing the parameter type. Only when you need to specify them
|
|
16
|
+
* are, you want to use the `uuid` type.
|
|
12
17
|
*
|
|
13
18
|
* ```typescript
|
|
14
|
-
* \@TypedRoute.Get("shopping/sales/:
|
|
19
|
+
* \@TypedRoute.Get("shopping/sales/:id/:no/:paused")
|
|
15
20
|
* public async pause
|
|
16
21
|
* (
|
|
17
|
-
* \@TypedParam("
|
|
18
|
-
* \@TypedParam("
|
|
19
|
-
* \@TypedParam("paused"
|
|
22
|
+
* \@TypedParam("id", "uuid"), id: string, // uuid specification
|
|
23
|
+
* \@TypedParam("no") id: number, // auto casting
|
|
24
|
+
* \@TypedParam("paused") paused: boolean | null // auto casting
|
|
20
25
|
* ): Promise<void>;
|
|
21
26
|
* ```
|
|
22
27
|
*
|
|
23
28
|
* @param name URL Parameter name
|
|
24
|
-
* @param type
|
|
29
|
+
* @param type If omit, automatically determined by the parameter type.
|
|
30
|
+
* @param nullable If omit, automatically determined by the parameter type.
|
|
25
31
|
* @returns Parameter decorator
|
|
26
32
|
*
|
|
27
33
|
* @author Jeongho Nam - https://github.com/samchon
|
|
28
34
|
*/
|
|
29
35
|
function TypedParam(name, type, nullable) {
|
|
30
|
-
if (type === void 0) { type = "string"; }
|
|
31
|
-
if (nullable === void 0) { nullable = false; }
|
|
32
36
|
return (0, common_1.createParamDecorator)(function TypedParam(_a, ctx) {
|
|
33
37
|
var request = ctx.switchToHttp().getRequest();
|
|
34
38
|
var str = request.params[name];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedParam.js","sourceRoot":"","sources":["../../src/decorators/TypedParam.ts"],"names":[],"mappings":";;;AAAA,yCAIwB;AAGx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CAAC,CAAC,IAAI,CAAC,CAAC;AACb,CAAC;AAnCD,gCAmCC;AAED,IAAM,YAAY,GACd,qHAAqH,CAAC"}
|
|
@@ -39,7 +39,7 @@ var e_1, _a, e_2, _b, e_3, _c;
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.TypedRoute = void 0;
|
|
41
41
|
var common_1 = require("@nestjs/common");
|
|
42
|
-
var
|
|
42
|
+
var operators_1 = require("rxjs/operators");
|
|
43
43
|
var typia_1 = require("typia");
|
|
44
44
|
var get_path_and_stringify_1 = require("./internal/get_path_and_stringify");
|
|
45
45
|
var route_error_1 = require("./internal/route_error");
|
|
@@ -169,7 +169,7 @@ var TypedRouteInterceptor = /** @class */ (function () {
|
|
|
169
169
|
var http = context.switchToHttp();
|
|
170
170
|
var response = http.getResponse();
|
|
171
171
|
response.header("Content-Type", "application/json");
|
|
172
|
-
return next.handle().pipe((0,
|
|
172
|
+
return next.handle().pipe((0, operators_1.map)(function (value) { return _this.stringify(value); }), (0, operators_1.catchError)(function (err) { return (0, route_error_1.route_error)(http.getRequest(), err); }));
|
|
173
173
|
};
|
|
174
174
|
return TypedRouteInterceptor;
|
|
175
175
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedRoute.js","sourceRoot":"","sources":["../../src/decorators/TypedRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAWwB;AAGxB,
|
|
1
|
+
{"version":3,"file":"TypedRoute.js","sourceRoot":"","sources":["../../src/decorators/TypedRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAWwB;AAGxB,4CAAiD;AAEjD,+BAKe;AAGf,4EAA2E;AAC3E,sDAAqD;AAErD;;;;;;;;;;;;;GAaG;AACH,IAAiB,UAAU,CAiE1B;AAjED,WAAiB,UAAU;IACvB;;;;;OAKG;IACU,c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wBACd,UAAU,CAAC,KAAK;qBACnB,CAAA,CAAA,gBAAA;wBANI,IAAM,IAAI,WAAA;wBAOV,IAAY,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;qBAAA;;;;;;;;;aAAA;;;;;;;;;KAAA;;;;;;;;;AAEvC;;GAEG;AACH;IACI,+BAAoC,SAAiC;QAAjC,cAAS,GAAT,SAAS,CAAwB;IAAG,CAAC;IAElE,yCAAS,GAAhB,UAAiB,OAAyB,EAAE,IAAiB;QAA7D,iBASC;QARG,IAAM,IAAI,GAAsB,OAAO,CAAC,YAAY,EAAE,CAAC;QACvD,IAAM,QAAQ,GAAqB,IAAI,CAAC,WAAW,EAAE,CAAC;QACtD,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAEpD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACrB,IAAA,eAAG,EAAC,UAAC,KAAK,IAAK,OAAA,KAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAArB,CAAqB,CAAC,EACrC,IAAA,sBAAU,EAAC,UAAC,GAAG,IAAK,OAAA,IAAA,yBAAW,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,EAAnC,CAAmC,CAAC,CAC3D,CAAC;IACN,CAAC;IACL,4BAAC;AAAD,CAAC,AAbD,IAaC;AAED;;GAEG;AACH,IAAM,OAAO,GAAG;IACZ,GAAG,cAAA;IACH,IAAI,eAAA;IACJ,KAAK,gBAAA;IACL,GAAG,cAAA;IACH,MAAM,iBAAA;CACT,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import express from "express";
|
|
2
|
-
|
|
3
|
-
export declare function route_error(request: express.Request, error: any): Observable<never>;
|
|
2
|
+
export declare function route_error(request: express.Request, error: any): import("rxjs").Observable<never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route_error.js","sourceRoot":"","sources":["../../../src/decorators/internal/route_error.ts"],"names":[],"mapp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A,iBAAU,EAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;AACnC,CAAC;AA5BD,kCA4BC"}
|
|
@@ -31,15 +31,15 @@ var TypedBodyProgrammer;
|
|
|
31
31
|
numeric: false,
|
|
32
32
|
finite: false,
|
|
33
33
|
functional: false,
|
|
34
|
-
} })
|
|
34
|
+
} }))(modulo)(false)(type)),
|
|
35
35
|
]);
|
|
36
36
|
};
|
|
37
37
|
// RETURNS
|
|
38
38
|
if (project.options.validate === "is")
|
|
39
|
-
return parameter("is", IsProgrammer_1.IsProgrammer.
|
|
39
|
+
return parameter("is", IsProgrammer_1.IsProgrammer.write);
|
|
40
40
|
else if (project.options.validate === "validate")
|
|
41
|
-
return parameter("validate", ValidateProgrammer_1.ValidateProgrammer.
|
|
42
|
-
return parameter("assert", AssertProgrammer_1.AssertProgrammer.
|
|
41
|
+
return parameter("validate", ValidateProgrammer_1.ValidateProgrammer.write);
|
|
42
|
+
return parameter("assert", AssertProgrammer_1.AssertProgrammer.write);
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
})(TypedBodyProgrammer = exports.TypedBodyProgrammer || (exports.TypedBodyProgrammer = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedBodyProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedBodyProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,2EAA0E;AAC1E,mEAAkE;AAClE,+EAA8E;AAK9E,IAAiB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"TypedBodyProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedBodyProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,2EAA0E;AAC1E,mEAAkE;AAClE,+EAA8E;AAK9E,IAAiB,mBAAmB,CAsCnC;AAtCD,WAAiB,mBAAmB;IACnB,4BAAQ,GACjB,UAAC,OAAgC,EAAE,MAAiC;QACpE,OAAA,UAAC,IAAa;YACV,2BAA2B;YAC3B,IAAM,SAAS,GAAG,UACd,GAAW,EACX,UAI6D;gBAE7D,OAAA,oBAAE,CAAC,OAAO,CAAC,6BAA6B,CAAC;oBACrC,oBAAE,CAAC,OAAO,CAAC,wBAAwB,CAC/B,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EACnC,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CACtC;oBACD,oBAAE,CAAC,OAAO,CAAC,wBAAwB,CAC/B,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAChC,UAAU,uBACH,OAAO,KACV,OAAO,EAAE;4BACL,OAAO,EAAE,KAAK;4BACd,MAAM,EAAE,KAAK;4BACb,UAAU,EAAE,KAAK;yBACpB,IACH,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAC1B;iBACJ,CAAC;YAhBF,CAgBE,CAAC;YAEP,UAAU;YACV,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI;gBACjC,OAAO,SAAS,CAAC,IAAI,EAAE,2BAAY,CAAC,KAAK,CAAC,CAAC;iBAC1C,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,UAAU;gBAC5C,OAAO,SAAS,CAAC,UAAU,EAAE,uCAAkB,CAAC,KAAK,CAAC,CAAC;YAC3D,OAAO,SAAS,CAAC,QAAQ,EAAE,mCAAgB,CAAC,KAAK,CAAC,CAAC;QACvD,CAAC;IAlCD,CAkCC,CAAC;AACV,CAAC,EAtCgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAsCnC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
3
|
+
export declare namespace TypedParamProgrammer {
|
|
4
|
+
const generate: ({ checker }: INestiaTransformProject) => (parameters: readonly ts.Expression[]) => (type: ts.Type) => readonly ts.Expression[];
|
|
5
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.TypedParamProgrammer = void 0;
|
|
32
|
+
var typescript_1 = __importDefault(require("typescript"));
|
|
33
|
+
var MetadataCollection_1 = require("typia/lib/factories/MetadataCollection");
|
|
34
|
+
var MetadataFactory_1 = require("typia/lib/factories/MetadataFactory");
|
|
35
|
+
var TypedParamProgrammer;
|
|
36
|
+
(function (TypedParamProgrammer) {
|
|
37
|
+
TypedParamProgrammer.generate = function (_a) {
|
|
38
|
+
var checker = _a.checker;
|
|
39
|
+
return function (parameters) {
|
|
40
|
+
return function (type) {
|
|
41
|
+
var metadata = MetadataFactory_1.MetadataFactory.analyze(checker)({
|
|
42
|
+
resolve: false,
|
|
43
|
+
constant: true,
|
|
44
|
+
validate: validate,
|
|
45
|
+
})(new MetadataCollection_1.MetadataCollection())(type);
|
|
46
|
+
var _a = __read(get_atomic_types(metadata), 1), atomic = _a[0];
|
|
47
|
+
// AUTO TYPE SPECIFICATION
|
|
48
|
+
if (parameters.length === 1)
|
|
49
|
+
return [
|
|
50
|
+
parameters[0],
|
|
51
|
+
typescript_1.default.factory.createStringLiteral(atomic),
|
|
52
|
+
metadata.nullable
|
|
53
|
+
? typescript_1.default.factory.createTrue()
|
|
54
|
+
: typescript_1.default.factory.createFalse(),
|
|
55
|
+
];
|
|
56
|
+
// TYPE HAS BEEN SPECIFIED IN DECORATOR
|
|
57
|
+
var specified = MetadataFactory_1.MetadataFactory.analyze(checker)({
|
|
58
|
+
resolve: false,
|
|
59
|
+
constant: true,
|
|
60
|
+
})(new MetadataCollection_1.MetadataCollection())(checker.getTypeAtLocation(parameters[1]));
|
|
61
|
+
if (equals(atomic, specified) === false)
|
|
62
|
+
throw new Error(error("different type between parameter and variable"));
|
|
63
|
+
if (parameters.length === 2)
|
|
64
|
+
return [
|
|
65
|
+
parameters[0],
|
|
66
|
+
parameters[1],
|
|
67
|
+
metadata.nullable
|
|
68
|
+
? typescript_1.default.factory.createTrue()
|
|
69
|
+
: typescript_1.default.factory.createFalse(),
|
|
70
|
+
];
|
|
71
|
+
// NULLABLE HAS BEEN SPECIFIED
|
|
72
|
+
var nullable = MetadataFactory_1.MetadataFactory.analyze(checker)({
|
|
73
|
+
resolve: false,
|
|
74
|
+
constant: true,
|
|
75
|
+
})(new MetadataCollection_1.MetadataCollection())(checker.getTypeAtLocation(parameters[2]));
|
|
76
|
+
if (nullable.getName() !== "true" && nullable.getName() !== "false")
|
|
77
|
+
throw new Error(error("nullable value must be literal type"));
|
|
78
|
+
else if (metadata.nullable !== (nullable.getName() === "true"))
|
|
79
|
+
throw new Error(error("different type (nullable) between parameter and variable"));
|
|
80
|
+
return parameters;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
})(TypedParamProgrammer = exports.TypedParamProgrammer || (exports.TypedParamProgrammer = {}));
|
|
85
|
+
var validate = function (meta) {
|
|
86
|
+
if (meta.any)
|
|
87
|
+
throw new Error(error("do not allow any type"));
|
|
88
|
+
else if (meta.required === false)
|
|
89
|
+
throw new Error(error("do not allow undefindable type"));
|
|
90
|
+
var atomics = get_atomic_types(meta);
|
|
91
|
+
var expected = meta.atomics.length +
|
|
92
|
+
meta.constants.map(function (c) { return c.values.length; }).reduce(function (a, b) { return a + b; }, 0);
|
|
93
|
+
if (meta.size() !== expected || atomics.length === 0)
|
|
94
|
+
throw new Error(error("only atomic or constant types is allowed"));
|
|
95
|
+
else if (atomics.length > 1)
|
|
96
|
+
throw new Error(error("do not allow union type"));
|
|
97
|
+
};
|
|
98
|
+
var get_atomic_types = function (meta) { return __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(meta.atomics), false), __read(meta.constants.map(function (c) { return c.type; })), false))), false); };
|
|
99
|
+
var error = function (message) {
|
|
100
|
+
return "Error on nestia.core.TypedParam(): ".concat(message, ".");
|
|
101
|
+
};
|
|
102
|
+
var equals = function (atomic, p) {
|
|
103
|
+
var name = p.getName();
|
|
104
|
+
if (atomic === "string")
|
|
105
|
+
return name === "\"string\"" || name === "\"uuid\"";
|
|
106
|
+
return "\"".concat(atomic, "\"") === name;
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=TypedParamProgrammer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedParamProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedParamProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA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
|
72
72
|
var collection = new MetadataCollection_1.MetadataCollection();
|
|
73
|
-
var metadata = MetadataFactory_1.MetadataFactory.
|
|
73
|
+
var metadata = MetadataFactory_1.MetadataFactory.analyze(checker)({
|
|
74
74
|
resolve: false,
|
|
75
75
|
constant: true,
|
|
76
|
-
});
|
|
76
|
+
})(collection)(type);
|
|
77
77
|
if (metadata.objects.length !== 1 || metadata.bucket() !== 1)
|
|
78
78
|
throw new Error(ErrorMessages.object(metadata)("only one object type is allowed."));
|
|
79
79
|
else if (metadata.nullable === true)
|
|
@@ -198,9 +198,9 @@ var TypedQueryProgrammer;
|
|
|
198
198
|
};
|
|
199
199
|
var decode_object = function (project, modulo) {
|
|
200
200
|
return function (type, object) {
|
|
201
|
-
var assert = AssertProgrammer_1.AssertProgrammer.
|
|
201
|
+
var assert = AssertProgrammer_1.AssertProgrammer.write(__assign(__assign({}, project), { options: {
|
|
202
202
|
numeric: true,
|
|
203
|
-
} })
|
|
203
|
+
} }))(modulo)(false)(type);
|
|
204
204
|
var output = typescript_1.default.factory.createIdentifier("output");
|
|
205
205
|
var importer = new FunctionImporeter_1.FunctionImporter();
|
|
206
206
|
var statements = [
|
|
@@ -233,7 +233,7 @@ var TypedQueryProgrammer;
|
|
|
233
233
|
: [meta.constants[0].type, true];
|
|
234
234
|
})(), 2), type = _a[0], isArray = _a[1];
|
|
235
235
|
return typescript_1.default.factory.createPropertyAssignment(key, isArray
|
|
236
|
-
? typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.
|
|
236
|
+
? typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("input.getAll"), undefined, [typescript_1.default.factory.createStringLiteral(key)]))("map"), undefined, [
|
|
237
237
|
typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("elem")], undefined, undefined, decode_value(importer)(type)(typescript_1.default.factory.createIdentifier("elem"))),
|
|
238
238
|
])
|
|
239
239
|
: decode_value(importer)(type)(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("input.get"), undefined, [typescript_1.default.factory.createStringLiteral(key)])));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedQueryProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedQueryProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,2EAA0E;AAC1E,6EAA4E;AAC5E,uEAAsE;AACtE,yEAAwE;AAIxE,2EAA0E;AAC1E,qFAAmF;AAKnF,IAAiB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"TypedQueryProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedQueryProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,2EAA0E;AAC1E,6EAA4E;AAC5E,uEAAsE;AACtE,yEAAwE;AAIxE,2EAA0E;AAC1E,qFAAmF;AAKnF,IAAiB,oBAAoB,CAwNpC;AAxND,WAAiB,oBAAoB;IACpB,6BAAQ,GACjB,UAAC,OAAgC,EAAE,MAAiC;QACpE,OAAA,UAAC,IAAa;YACV,IAAM,MAAM,GAAmB,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;YAChE,OAAO,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;IAHD,CAGC,CAAC;IAEN,IAAM,SAAS,GACX,UAAC,OAAuB;QACxB,OAAA,UAAC,IAAa;;YACV,IAAM,UAAU,GAAuB,IAAI,uCAAkB,EAAE,CAAC;YAChE,IAAM,QAAQ,GAAa,iCAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBACxD,OAAO,EAAE,K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AK,OAAA,UAAC,GAAa,IAAK,OAAA,UAAC,OAAe;QACxD,OAAA,0CACI,GAAG,CAAC,IAAI,2BACK,GAAG,CAAC,OAAO,EAAE,gBAAM,OAAO,CAAE;IAF7C,CAE6C,EAHL,CAGK,EAHxB,CAGwB,CAAC;AAC1D,CAAC,EATS,aAAa,KAAb,aAAa,QAStB"}
|
|
@@ -28,20 +28,20 @@ var TypedRouteProgrammer;
|
|
|
28
28
|
var parameter = function (key, programmer) {
|
|
29
29
|
return typescript_1.default.factory.createObjectLiteralExpression([
|
|
30
30
|
typescript_1.default.factory.createPropertyAssignment(typescript_1.default.factory.createIdentifier("type"), typescript_1.default.factory.createStringLiteral(key)),
|
|
31
|
-
typescript_1.default.factory.createPropertyAssignment(typescript_1.default.factory.createIdentifier(key), programmer(__assign(__assign({}, project), { options: {} })
|
|
31
|
+
typescript_1.default.factory.createPropertyAssignment(typescript_1.default.factory.createIdentifier(key), programmer(__assign(__assign({}, project), { options: {} }))(modulo)(type)),
|
|
32
32
|
]);
|
|
33
33
|
};
|
|
34
34
|
// RETURNS
|
|
35
35
|
if (project.options.stringify === "is")
|
|
36
|
-
return parameter("is", IsStringifyProgrammer_1.IsStringifyProgrammer.
|
|
36
|
+
return parameter("is", IsStringifyProgrammer_1.IsStringifyProgrammer.write);
|
|
37
37
|
else if (project.options.stringify === "validate")
|
|
38
|
-
return parameter("validate", ValidateStringifyProgrammer_1.ValidateStringifyProgrammer.
|
|
38
|
+
return parameter("validate", ValidateStringifyProgrammer_1.ValidateStringifyProgrammer.write);
|
|
39
39
|
else if (project.options.stringify === "stringify")
|
|
40
|
-
return parameter("stringify", StringifyProgrammer_1.StringifyProgrammer.
|
|
40
|
+
return parameter("stringify", StringifyProgrammer_1.StringifyProgrammer.write);
|
|
41
41
|
else if (project.options.stringify === null)
|
|
42
42
|
return typescript_1.default.factory.createNull();
|
|
43
43
|
// ASSERT IS DEFAULT
|
|
44
|
-
return parameter("assert", AssertStringifyProgrammer_1.AssertStringifyProgrammer.
|
|
44
|
+
return parameter("assert", AssertStringifyProgrammer_1.AssertStringifyProgrammer.write);
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
})(TypedRouteProgrammer = exports.TypedRouteProgrammer || (exports.TypedRouteProgrammer = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedRouteProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedRouteProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,6FAA4F;AAC5F,qFAAoF;AACpF,iFAAgF;AAChF,iGAAgG;AAKhG,IAAiB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"TypedRouteProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedRouteProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,6FAA4F;AAC5F,qFAAoF;AACpF,iFAAgF;AAChF,iGAAgG;AAKhG,IAAiB,oBAAoB,CAwCpC;AAxCD,WAAiB,oBAAoB;IACpB,6BAAQ,GACjB,UAAC,OAAgC,EAAE,MAAiC;QACpE,OAAA,UAAC,IAAa;YACV,0BAA0B;YAC1B,IAAM,SAAS,GAAG,UACd,GAAW,EACX,UAIwC;gBAExC,OAAA,oBAAE,CAAC,OAAO,CAAC,6BAA6B,CAAC;oBACrC,oBAAE,CAAC,OAAO,CAAC,wBAAwB,CAC/B,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EACnC,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CACtC;oBACD,oBAAE,CAAC,OAAO,CAAC,wBAAwB,CAC/B,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAChC,UAAU,uBACH,OAAO,KACV,OAAO,EAAE,EAAE,IACb,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CACnB;iBACJ,CAAC;YAZF,CAYE,CAAC;YAEP,UAAU;YACV,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI;gBAClC,OAAO,SAAS,CAAC,IAAI,EAAE,6CAAqB,CAAC,KAAK,CAAC,CAAC;iBACnD,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,KAAK,UAAU;gBAC7C,OAAO,SAAS,CAAC,UAAU,EAAE,yDAA2B,CAAC,KAAK,CAAC,CAAC;iBAC/D,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,KAAK,WAAW;gBAC9C,OAAO,SAAS,CAAC,WAAW,EAAE,yCAAmB,CAAC,KAAK,CAAC,CAAC;iBACxD,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI;gBACvC,OAAO,oBAAE,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YAEnC,oBAAoB;YACpB,OAAO,SAAS,CAAC,QAAQ,EAAE,qDAAyB,CAAC,KAAK,CAAC,CAAC;QAChE,CAAC;IApCD,CAoCC,CAAC;AACV,CAAC,EAxCgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAwCpC"}
|
|
@@ -7,19 +7,18 @@ exports.ParameterDecoratorTransformer = void 0;
|
|
|
7
7
|
var path_1 = __importDefault(require("path"));
|
|
8
8
|
var typescript_1 = __importDefault(require("typescript"));
|
|
9
9
|
var TypedBodyProgrammer_1 = require("../programmers/TypedBodyProgrammer");
|
|
10
|
+
var TypedParamProgrammer_1 = require("../programmers/TypedParamProgrammer");
|
|
10
11
|
var TypedQueryProgrammer_1 = require("../programmers/TypedQueryProgrammer");
|
|
11
12
|
var ParameterDecoratorTransformer;
|
|
12
13
|
(function (ParameterDecoratorTransformer) {
|
|
13
14
|
function transform(project, type, decorator) {
|
|
14
|
-
var _a
|
|
15
|
+
var _a;
|
|
15
16
|
//----
|
|
16
17
|
// VALIDATIONS
|
|
17
18
|
//----
|
|
18
19
|
// CHECK DECORATOR
|
|
19
20
|
if (!typescript_1.default.isCallExpression(decorator.expression))
|
|
20
21
|
return decorator;
|
|
21
|
-
else if (decorator.expression.arguments.length !== 0)
|
|
22
|
-
return decorator;
|
|
23
22
|
// SIGNATURE DECLARATION
|
|
24
23
|
var declaration = (_a = project.checker.getResolvedSignature(decorator.expression)) === null || _a === void 0 ? void 0 : _a.declaration;
|
|
25
24
|
if (declaration === undefined)
|
|
@@ -32,7 +31,7 @@ var ParameterDecoratorTransformer;
|
|
|
32
31
|
// TRANSFORMATION
|
|
33
32
|
//----
|
|
34
33
|
// FIND PROGRAMMER
|
|
35
|
-
var programmer =
|
|
34
|
+
var programmer = FUNCTORS[project.checker.getTypeAtLocation(declaration).symbol.name];
|
|
36
35
|
if (programmer === undefined)
|
|
37
36
|
return decorator;
|
|
38
37
|
// GET TYPE INFO
|
|
@@ -40,14 +39,27 @@ var ParameterDecoratorTransformer;
|
|
|
40
39
|
if (typeNode === undefined)
|
|
41
40
|
return decorator;
|
|
42
41
|
// DO TRANSFORM
|
|
43
|
-
return typescript_1.default.factory.createDecorator(typescript_1.default.factory.updateCallExpression(decorator.expression, decorator.expression.expression, decorator.expression.typeArguments,
|
|
42
|
+
return typescript_1.default.factory.createDecorator(typescript_1.default.factory.updateCallExpression(decorator.expression, decorator.expression.expression, decorator.expression.typeArguments, programmer(project, decorator.expression.expression)(decorator.expression.arguments)(type)));
|
|
44
43
|
}
|
|
45
44
|
ParameterDecoratorTransformer.transform = transform;
|
|
46
45
|
})(ParameterDecoratorTransformer = exports.ParameterDecoratorTransformer || (exports.ParameterDecoratorTransformer = {}));
|
|
47
46
|
var FUNCTORS = {
|
|
48
|
-
EncryptedBody: function () { return
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
EncryptedBody: function (project, modulo) { return function (parameters) { return function (type) {
|
|
48
|
+
return parameters.length
|
|
49
|
+
? parameters
|
|
50
|
+
: [TypedBodyProgrammer_1.TypedBodyProgrammer.generate(project, modulo)(type)];
|
|
51
|
+
}; }; },
|
|
52
|
+
TypedBody: function (project, modulo) { return function (parameters) { return function (type) {
|
|
53
|
+
return parameters.length
|
|
54
|
+
? parameters
|
|
55
|
+
: [TypedBodyProgrammer_1.TypedBodyProgrammer.generate(project, modulo)(type)];
|
|
56
|
+
}; }; },
|
|
57
|
+
TypedParam: TypedParamProgrammer_1.TypedParamProgrammer.generate,
|
|
58
|
+
TypedQuery: function (project, modulo) { return function (parameters) { return function (type) {
|
|
59
|
+
return parameters.length
|
|
60
|
+
? parameters
|
|
61
|
+
: [TypedQueryProgrammer_1.TypedQueryProgrammer.generate(project, modulo)(type)];
|
|
62
|
+
}; }; },
|
|
51
63
|
};
|
|
52
64
|
var LIB_PATH = path_1.default.join("node_modules", "@nestia", "core", "lib", "decorators");
|
|
53
65
|
var SRC_PATH = path_1.default.resolve(path_1.default.join(__dirname, "..", "decorators"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParameterDecoratorTransformer.js","sourceRoot":"","sources":["../../src/transformers/ParameterDecoratorTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwB;AACxB,0DAA4B;AAG5B,0EAAyE;AACzE,4EAA2E;AAE3E,IAAiB,6BAA6B,
|
|
1
|
+
{"version":3,"file":"ParameterDecoratorTransformer.js","sourceRoot":"","sources":["../../src/transformers/ParameterDecoratorTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwB;AACxB,0DAA4B;AAG5B,0EAAyE;AACzE,4EAA2E;AAC3E,4EAA2E;AAE3E,IAAiB,6BAA6B,CAoD7C;AApDD,WAAiB,6BAA6B;IAC1C,SAAgB,SAAS,CACrB,OAAgC,EAChC,IAAa,EACb,SAAuB;;QAEvB,MAAM;QACN,cAAc;QACd,MAAM;QACN,kBAAkB;QAClB,IAAI,CAAC,oBAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;YAAE,OAAO,SAAS,CAAC;QAEjE,wBAAwB;QACxB,IAAM,WAAW,GACb,MAAA,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAChC,SAAS,CAAC,UAA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ev.
|
|
3
|
+
"version": "1.1.0-dev.20230420",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"dev": "npm run build -- --watch",
|
|
11
11
|
"eslint": "eslint ./**/*.ts",
|
|
12
12
|
"eslint:fix": "eslint ./**/*.ts --fix",
|
|
13
|
-
"package": "npm publish --access public",
|
|
13
|
+
"package:latest": "npm run build && npm run build:test && npm run test && npm publish --access public",
|
|
14
|
+
"package:next": "npm run package:latest -- --tag next",
|
|
14
15
|
"prepare": "ts-patch install",
|
|
15
16
|
"prettier": "prettier ./**/*.ts --write",
|
|
16
17
|
"test": "node bin/test"
|
|
@@ -34,6 +35,20 @@
|
|
|
34
35
|
"url": "https://github.com/samchon/nestia/issues"
|
|
35
36
|
},
|
|
36
37
|
"homepage": "https://github.com/samchon/nestia",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@nestia/fetcher": "^1.1.0-dev.20230420-2",
|
|
40
|
+
"@nestjs/common": ">= 7.0.1",
|
|
41
|
+
"@nestjs/core": ">= 7.0.1",
|
|
42
|
+
"@nestjs/platform-express": ">= 7.0.1",
|
|
43
|
+
"detect-ts-node": "^1.0.5",
|
|
44
|
+
"raw-body": ">= 2.0.0",
|
|
45
|
+
"reflect-metadata": ">= 0.1.12",
|
|
46
|
+
"rxjs": ">= 6.0.0",
|
|
47
|
+
"typia": "^3.8.0-dev.20230420-2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"typescript": ">= 4.5.2"
|
|
51
|
+
},
|
|
37
52
|
"devDependencies": {
|
|
38
53
|
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
|
|
39
54
|
"@types/express": "^4.17.15",
|
|
@@ -48,25 +63,11 @@
|
|
|
48
63
|
"prettier": "^2.8.7",
|
|
49
64
|
"rimraf": "^3.0.2",
|
|
50
65
|
"ts-node": "^10.9.1",
|
|
51
|
-
"ts-patch": "
|
|
66
|
+
"ts-patch": "3.0.0-beta3",
|
|
52
67
|
"tstl": "^2.5.13",
|
|
53
68
|
"typescript": "^5.0.4",
|
|
54
69
|
"typescript-transform-paths": "^3.4.6"
|
|
55
70
|
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@nestia/fetcher": "^1.0.0",
|
|
58
|
-
"@nestjs/common": "*",
|
|
59
|
-
"@nestjs/core": "*",
|
|
60
|
-
"@nestjs/platform-express": "*",
|
|
61
|
-
"detect-ts-node": "^1.0.5",
|
|
62
|
-
"raw-body": "*",
|
|
63
|
-
"reflect-metadata": "*",
|
|
64
|
-
"rxjs": "*",
|
|
65
|
-
"typia": "^3.7.4"
|
|
66
|
-
},
|
|
67
|
-
"peerDependencies": {
|
|
68
|
-
"typescript": ">= 4.5.2"
|
|
69
|
-
},
|
|
70
71
|
"files": [
|
|
71
72
|
"README.md",
|
|
72
73
|
"LICENSE",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
|
|
2
|
-
import { Module
|
|
2
|
+
import { Module } from "@nestjs/common";
|
|
3
3
|
|
|
4
4
|
import { Creator } from "../typings/Creator";
|
|
5
5
|
import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
|
|
@@ -36,7 +36,7 @@ import { load_controllers } from "./internal/load_controller";
|
|
|
36
36
|
* @author Jeongho Nam - https://github.com/samchon
|
|
37
37
|
*/
|
|
38
38
|
export function EncryptedModule(
|
|
39
|
-
metadata:
|
|
39
|
+
metadata: Parameters<typeof Module>[0],
|
|
40
40
|
password: IEncryptionPassword | IEncryptionPassword.Closure,
|
|
41
41
|
): ClassDecorator {
|
|
42
42
|
return function (target: any) {
|
|
@@ -66,7 +66,7 @@ export namespace EncryptedModule {
|
|
|
66
66
|
export async function dynamic(
|
|
67
67
|
path: string,
|
|
68
68
|
password: IEncryptionPassword | IEncryptionPassword.Closure,
|
|
69
|
-
options: Omit<
|
|
69
|
+
options: Omit<Parameters<typeof Module>[0], "controllers"> = {},
|
|
70
70
|
): Promise<object> {
|
|
71
71
|
// LOAD CONTROLLERS
|
|
72
72
|
const controllers: Creator<object>[] = await load_controllers(path);
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "@nestjs/common";
|
|
14
14
|
import { HttpArgumentsHost } from "@nestjs/common/interfaces";
|
|
15
15
|
import express from "express";
|
|
16
|
-
import {
|
|
16
|
+
import { catchError, map } from "rxjs/operators";
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
assertStringify,
|
|
@@ -141,10 +141,7 @@ class EncryptedRouteInterceptor implements NestInterceptor {
|
|
|
141
141
|
private readonly stringify: (input: any) => string,
|
|
142
142
|
) {}
|
|
143
143
|
|
|
144
|
-
public intercept(
|
|
145
|
-
context: ExecutionContext,
|
|
146
|
-
next: CallHandler,
|
|
147
|
-
): Observable<any> {
|
|
144
|
+
public intercept(context: ExecutionContext, next: CallHandler) {
|
|
148
145
|
const http: HttpArgumentsHost = context.switchToHttp();
|
|
149
146
|
return next.handle().pipe(
|
|
150
147
|
map((value) => {
|
|
@@ -10,29 +10,35 @@ import type express from "express";
|
|
|
10
10
|
*
|
|
11
11
|
* `TypedParam` is a decorator function getting specific typed parameter from the
|
|
12
12
|
* HTTP request URL. It's almost same with the {@link nest.Param}, but `TypedParam`
|
|
13
|
-
*
|
|
14
|
-
* parses all of the parameters as string type.
|
|
13
|
+
* automatically casts parameter value to be following its type. Beside, the
|
|
14
|
+
* {@link nest.Param} always parses all of the parameters as `string` type.
|
|
15
|
+
*
|
|
16
|
+
* Note that, if you just omit the `type` and `nullable` parameters, then
|
|
17
|
+
* `TypedParam` automatically determines the `type` and `nullable` values
|
|
18
|
+
* just by analyzing the parameter type. Only when you need to specify them
|
|
19
|
+
* are, you want to use the `uuid` type.
|
|
15
20
|
*
|
|
16
21
|
* ```typescript
|
|
17
|
-
* \@TypedRoute.Get("shopping/sales/:
|
|
22
|
+
* \@TypedRoute.Get("shopping/sales/:id/:no/:paused")
|
|
18
23
|
* public async pause
|
|
19
24
|
* (
|
|
20
|
-
* \@TypedParam("
|
|
21
|
-
* \@TypedParam("
|
|
22
|
-
* \@TypedParam("paused"
|
|
25
|
+
* \@TypedParam("id", "uuid"), id: string, // uuid specification
|
|
26
|
+
* \@TypedParam("no") id: number, // auto casting
|
|
27
|
+
* \@TypedParam("paused") paused: boolean | null // auto casting
|
|
23
28
|
* ): Promise<void>;
|
|
24
29
|
* ```
|
|
25
30
|
*
|
|
26
31
|
* @param name URL Parameter name
|
|
27
|
-
* @param type
|
|
32
|
+
* @param type If omit, automatically determined by the parameter type.
|
|
33
|
+
* @param nullable If omit, automatically determined by the parameter type.
|
|
28
34
|
* @returns Parameter decorator
|
|
29
35
|
*
|
|
30
36
|
* @author Jeongho Nam - https://github.com/samchon
|
|
31
37
|
*/
|
|
32
38
|
export function TypedParam(
|
|
33
39
|
name: string,
|
|
34
|
-
type
|
|
35
|
-
nullable
|
|
40
|
+
type?: "boolean" | "number" | "string" | "uuid",
|
|
41
|
+
nullable?: false | true,
|
|
36
42
|
): ParameterDecorator {
|
|
37
43
|
return createParamDecorator(function TypedParam(
|
|
38
44
|
{}: any,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@nestjs/common";
|
|
13
13
|
import { HttpArgumentsHost } from "@nestjs/common/interfaces";
|
|
14
14
|
import express from "express";
|
|
15
|
-
import {
|
|
15
|
+
import { catchError, map } from "rxjs/operators";
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
assertStringify,
|
|
@@ -127,10 +127,7 @@ for (const method of [
|
|
|
127
127
|
class TypedRouteInterceptor implements NestInterceptor {
|
|
128
128
|
public constructor(private readonly stringify: (input: any) => string) {}
|
|
129
129
|
|
|
130
|
-
public intercept(
|
|
131
|
-
context: ExecutionContext,
|
|
132
|
-
next: CallHandler,
|
|
133
|
-
): Observable<any> {
|
|
130
|
+
public intercept(context: ExecutionContext, next: CallHandler) {
|
|
134
131
|
const http: HttpArgumentsHost = context.switchToHttp();
|
|
135
132
|
const response: express.Response = http.getResponse();
|
|
136
133
|
response.header("Content-Type", "application/json");
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { HttpException } from "@nestjs/common";
|
|
2
2
|
import express from "express";
|
|
3
|
-
import {
|
|
3
|
+
import { throwError } from "rxjs";
|
|
4
4
|
|
|
5
5
|
import { ExceptionManager } from "../../utils/ExceptionManager";
|
|
6
6
|
|
|
7
|
-
export function route_error(
|
|
8
|
-
request: express.Request,
|
|
9
|
-
error: any,
|
|
10
|
-
): Observable<never> {
|
|
7
|
+
export function route_error(request: express.Request, error: any) {
|
|
11
8
|
error = (() => {
|
|
12
9
|
// HTTP-ERROR
|
|
13
10
|
if (error instanceof HttpException) return error;
|
|
@@ -16,8 +16,9 @@ export namespace TypedBodyProgrammer {
|
|
|
16
16
|
key: string,
|
|
17
17
|
programmer: (
|
|
18
18
|
project: IProject,
|
|
19
|
+
) => (
|
|
19
20
|
modulo: ts.LeftHandSideExpression,
|
|
20
|
-
) => (type: ts.Type) => ts.ArrowFunction,
|
|
21
|
+
) => (equals: boolean) => (type: ts.Type) => ts.ArrowFunction,
|
|
21
22
|
) =>
|
|
22
23
|
ts.factory.createObjectLiteralExpression([
|
|
23
24
|
ts.factory.createPropertyAssignment(
|
|
@@ -26,25 +27,22 @@ export namespace TypedBodyProgrammer {
|
|
|
26
27
|
),
|
|
27
28
|
ts.factory.createPropertyAssignment(
|
|
28
29
|
ts.factory.createIdentifier(key),
|
|
29
|
-
programmer(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
functional: false,
|
|
36
|
-
},
|
|
30
|
+
programmer({
|
|
31
|
+
...project,
|
|
32
|
+
options: {
|
|
33
|
+
numeric: false,
|
|
34
|
+
finite: false,
|
|
35
|
+
functional: false,
|
|
37
36
|
},
|
|
38
|
-
|
|
39
|
-
)(type),
|
|
37
|
+
})(modulo)(false)(type),
|
|
40
38
|
),
|
|
41
39
|
]);
|
|
42
40
|
|
|
43
41
|
// RETURNS
|
|
44
42
|
if (project.options.validate === "is")
|
|
45
|
-
return parameter("is", IsProgrammer.
|
|
43
|
+
return parameter("is", IsProgrammer.write);
|
|
46
44
|
else if (project.options.validate === "validate")
|
|
47
|
-
return parameter("validate", ValidateProgrammer.
|
|
48
|
-
return parameter("assert", AssertProgrammer.
|
|
45
|
+
return parameter("validate", ValidateProgrammer.write);
|
|
46
|
+
return parameter("assert", AssertProgrammer.write);
|
|
49
47
|
};
|
|
50
48
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
4
|
+
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
5
|
+
import { Metadata } from "typia/lib/metadata/Metadata";
|
|
6
|
+
|
|
7
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
8
|
+
|
|
9
|
+
export namespace TypedParamProgrammer {
|
|
10
|
+
export const generate =
|
|
11
|
+
({ checker }: INestiaTransformProject) =>
|
|
12
|
+
(parameters: readonly ts.Expression[]) =>
|
|
13
|
+
(type: ts.Type): readonly ts.Expression[] => {
|
|
14
|
+
const metadata: Metadata = MetadataFactory.analyze(checker)({
|
|
15
|
+
resolve: false,
|
|
16
|
+
constant: true,
|
|
17
|
+
validate,
|
|
18
|
+
})(new MetadataCollection())(type);
|
|
19
|
+
const [atomic] = get_atomic_types(metadata);
|
|
20
|
+
|
|
21
|
+
// AUTO TYPE SPECIFICATION
|
|
22
|
+
if (parameters.length === 1)
|
|
23
|
+
return [
|
|
24
|
+
parameters[0],
|
|
25
|
+
ts.factory.createStringLiteral(atomic),
|
|
26
|
+
metadata.nullable
|
|
27
|
+
? ts.factory.createTrue()
|
|
28
|
+
: ts.factory.createFalse(),
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// TYPE HAS BEEN SPECIFIED IN DECORATOR
|
|
32
|
+
const specified: Metadata = MetadataFactory.analyze(checker)({
|
|
33
|
+
resolve: false,
|
|
34
|
+
constant: true,
|
|
35
|
+
})(new MetadataCollection())(
|
|
36
|
+
checker.getTypeAtLocation(parameters[1]),
|
|
37
|
+
);
|
|
38
|
+
if (equals(atomic, specified) === false)
|
|
39
|
+
throw new Error(
|
|
40
|
+
error("different type between parameter and variable"),
|
|
41
|
+
);
|
|
42
|
+
if (parameters.length === 2)
|
|
43
|
+
return [
|
|
44
|
+
parameters[0],
|
|
45
|
+
parameters[1],
|
|
46
|
+
metadata.nullable
|
|
47
|
+
? ts.factory.createTrue()
|
|
48
|
+
: ts.factory.createFalse(),
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
// NULLABLE HAS BEEN SPECIFIED
|
|
52
|
+
const nullable: Metadata = MetadataFactory.analyze(checker)({
|
|
53
|
+
resolve: false,
|
|
54
|
+
constant: true,
|
|
55
|
+
})(new MetadataCollection())(
|
|
56
|
+
checker.getTypeAtLocation(parameters[2]),
|
|
57
|
+
);
|
|
58
|
+
if (nullable.getName() !== "true" && nullable.getName() !== "false")
|
|
59
|
+
throw new Error(error("nullable value must be literal type"));
|
|
60
|
+
else if (metadata.nullable !== (nullable.getName() === "true"))
|
|
61
|
+
throw new Error(
|
|
62
|
+
error(
|
|
63
|
+
"different type (nullable) between parameter and variable",
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
return parameters;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const validate = (meta: Metadata) => {
|
|
71
|
+
if (meta.any) throw new Error(error("do not allow any type"));
|
|
72
|
+
else if (meta.required === false)
|
|
73
|
+
throw new Error(error("do not allow undefindable type"));
|
|
74
|
+
|
|
75
|
+
const atomics: string[] = get_atomic_types(meta);
|
|
76
|
+
const expected: number =
|
|
77
|
+
meta.atomics.length +
|
|
78
|
+
meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
|
|
79
|
+
if (meta.size() !== expected || atomics.length === 0)
|
|
80
|
+
throw new Error(error("only atomic or constant types is allowed"));
|
|
81
|
+
else if (atomics.length > 1)
|
|
82
|
+
throw new Error(error("do not allow union type"));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const get_atomic_types = (meta: Metadata): string[] => [
|
|
86
|
+
...new Set([...meta.atomics, ...meta.constants.map((c) => c.type)]),
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const error = (message: string) =>
|
|
90
|
+
`Error on nestia.core.TypedParam(): ${message}.`;
|
|
91
|
+
|
|
92
|
+
const equals = (atomic: string, p: Metadata) => {
|
|
93
|
+
const name: string = p.getName();
|
|
94
|
+
if (atomic === "string") return name === `"string"` || name === `"uuid"`;
|
|
95
|
+
return `"${atomic}"` === name;
|
|
96
|
+
};
|
|
@@ -25,15 +25,10 @@ export namespace TypedQueryProgrammer {
|
|
|
25
25
|
(checker: ts.TypeChecker) =>
|
|
26
26
|
(type: ts.Type): MetadataObject => {
|
|
27
27
|
const collection: MetadataCollection = new MetadataCollection();
|
|
28
|
-
const metadata: Metadata = MetadataFactory.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
resolve: false,
|
|
34
|
-
constant: true,
|
|
35
|
-
},
|
|
36
|
-
);
|
|
28
|
+
const metadata: Metadata = MetadataFactory.analyze(checker)({
|
|
29
|
+
resolve: false,
|
|
30
|
+
constant: true,
|
|
31
|
+
})(collection)(type);
|
|
37
32
|
if (metadata.objects.length !== 1 || metadata.bucket() !== 1)
|
|
38
33
|
throw new Error(
|
|
39
34
|
ErrorMessages.object(metadata)(
|
|
@@ -141,15 +136,12 @@ export namespace TypedQueryProgrammer {
|
|
|
141
136
|
const decode_object =
|
|
142
137
|
(project: INestiaTransformProject, modulo: ts.LeftHandSideExpression) =>
|
|
143
138
|
(type: ts.Type, object: MetadataObject): ts.ConciseBody => {
|
|
144
|
-
const assert: ts.ArrowFunction = AssertProgrammer.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
numeric: true,
|
|
149
|
-
},
|
|
139
|
+
const assert: ts.ArrowFunction = AssertProgrammer.write({
|
|
140
|
+
...project,
|
|
141
|
+
options: {
|
|
142
|
+
numeric: true,
|
|
150
143
|
},
|
|
151
|
-
|
|
152
|
-
)(type);
|
|
144
|
+
})(modulo)(false)(type);
|
|
153
145
|
const output = ts.factory.createIdentifier("output");
|
|
154
146
|
|
|
155
147
|
const importer = new FunctionImporter();
|
|
@@ -199,14 +191,13 @@ export namespace TypedQueryProgrammer {
|
|
|
199
191
|
key,
|
|
200
192
|
isArray
|
|
201
193
|
? ts.factory.createCallExpression(
|
|
202
|
-
IdentifierFactory.
|
|
194
|
+
IdentifierFactory.access(
|
|
203
195
|
ts.factory.createCallExpression(
|
|
204
196
|
ts.factory.createIdentifier("input.getAll"),
|
|
205
197
|
undefined,
|
|
206
198
|
[ts.factory.createStringLiteral(key)],
|
|
207
199
|
),
|
|
208
|
-
|
|
209
|
-
),
|
|
200
|
+
)("map"),
|
|
210
201
|
undefined,
|
|
211
202
|
[
|
|
212
203
|
ts.factory.createArrowFunction(
|
|
@@ -17,6 +17,7 @@ export namespace TypedRouteProgrammer {
|
|
|
17
17
|
key: string,
|
|
18
18
|
programmer: (
|
|
19
19
|
project: IProject,
|
|
20
|
+
) => (
|
|
20
21
|
modulo: ts.LeftHandSideExpression,
|
|
21
22
|
) => (type: ts.Type) => ts.ArrowFunction,
|
|
22
23
|
) =>
|
|
@@ -27,30 +28,24 @@ export namespace TypedRouteProgrammer {
|
|
|
27
28
|
),
|
|
28
29
|
ts.factory.createPropertyAssignment(
|
|
29
30
|
ts.factory.createIdentifier(key),
|
|
30
|
-
programmer(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
modulo,
|
|
36
|
-
)(type),
|
|
31
|
+
programmer({
|
|
32
|
+
...project,
|
|
33
|
+
options: {}, // use default option
|
|
34
|
+
})(modulo)(type),
|
|
37
35
|
),
|
|
38
36
|
]);
|
|
39
37
|
|
|
40
38
|
// RETURNS
|
|
41
39
|
if (project.options.stringify === "is")
|
|
42
|
-
return parameter("is", IsStringifyProgrammer.
|
|
40
|
+
return parameter("is", IsStringifyProgrammer.write);
|
|
43
41
|
else if (project.options.stringify === "validate")
|
|
44
|
-
return parameter(
|
|
45
|
-
"validate",
|
|
46
|
-
ValidateStringifyProgrammer.generate,
|
|
47
|
-
);
|
|
42
|
+
return parameter("validate", ValidateStringifyProgrammer.write);
|
|
48
43
|
else if (project.options.stringify === "stringify")
|
|
49
|
-
return parameter("stringify", StringifyProgrammer.
|
|
44
|
+
return parameter("stringify", StringifyProgrammer.write);
|
|
50
45
|
else if (project.options.stringify === null)
|
|
51
46
|
return ts.factory.createNull();
|
|
52
47
|
|
|
53
48
|
// ASSERT IS DEFAULT
|
|
54
|
-
return parameter("assert", AssertStringifyProgrammer.
|
|
49
|
+
return parameter("assert", AssertStringifyProgrammer.write);
|
|
55
50
|
};
|
|
56
51
|
}
|
|
@@ -3,6 +3,7 @@ import ts from "typescript";
|
|
|
3
3
|
|
|
4
4
|
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
5
5
|
import { TypedBodyProgrammer } from "../programmers/TypedBodyProgrammer";
|
|
6
|
+
import { TypedParamProgrammer } from "../programmers/TypedParamProgrammer";
|
|
6
7
|
import { TypedQueryProgrammer } from "../programmers/TypedQueryProgrammer";
|
|
7
8
|
|
|
8
9
|
export namespace ParameterDecoratorTransformer {
|
|
@@ -16,7 +17,6 @@ export namespace ParameterDecoratorTransformer {
|
|
|
16
17
|
//----
|
|
17
18
|
// CHECK DECORATOR
|
|
18
19
|
if (!ts.isCallExpression(decorator.expression)) return decorator;
|
|
19
|
-
else if (decorator.expression.arguments.length !== 0) return decorator;
|
|
20
20
|
|
|
21
21
|
// SIGNATURE DECLARATION
|
|
22
22
|
const declaration: ts.Declaration | undefined =
|
|
@@ -37,7 +37,7 @@ export namespace ParameterDecoratorTransformer {
|
|
|
37
37
|
const programmer: Programmer | undefined =
|
|
38
38
|
FUNCTORS[
|
|
39
39
|
project.checker.getTypeAtLocation(declaration).symbol.name
|
|
40
|
-
]
|
|
40
|
+
];
|
|
41
41
|
if (programmer === undefined) return decorator;
|
|
42
42
|
|
|
43
43
|
// GET TYPE INFO
|
|
@@ -51,22 +51,36 @@ export namespace ParameterDecoratorTransformer {
|
|
|
51
51
|
decorator.expression,
|
|
52
52
|
decorator.expression.expression,
|
|
53
53
|
decorator.expression.typeArguments,
|
|
54
|
-
|
|
54
|
+
programmer(
|
|
55
|
+
project,
|
|
56
|
+
decorator.expression.expression,
|
|
57
|
+
)(decorator.expression.arguments)(type),
|
|
55
58
|
),
|
|
56
59
|
);
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
type Programmer = (
|
|
64
|
+
project: INestiaTransformProject,
|
|
65
|
+
modulo: ts.LeftHandSideExpression,
|
|
66
|
+
) => (
|
|
67
|
+
parameters: readonly ts.Expression[],
|
|
68
|
+
) => (type: ts.Type) => readonly ts.Expression[];
|
|
65
69
|
|
|
66
|
-
const FUNCTORS: Record<string,
|
|
67
|
-
EncryptedBody: () =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
const FUNCTORS: Record<string, Programmer> = {
|
|
71
|
+
EncryptedBody: (project, modulo) => (parameters) => (type) =>
|
|
72
|
+
parameters.length
|
|
73
|
+
? parameters
|
|
74
|
+
: [TypedBodyProgrammer.generate(project, modulo)(type)],
|
|
75
|
+
TypedBody: (project, modulo) => (parameters) => (type) =>
|
|
76
|
+
parameters.length
|
|
77
|
+
? parameters
|
|
78
|
+
: [TypedBodyProgrammer.generate(project, modulo)(type)],
|
|
79
|
+
TypedParam: TypedParamProgrammer.generate,
|
|
80
|
+
TypedQuery: (project, modulo) => (parameters) => (type) =>
|
|
81
|
+
parameters.length
|
|
82
|
+
? parameters
|
|
83
|
+
: [TypedQueryProgrammer.generate(project, modulo)(type)],
|
|
70
84
|
};
|
|
71
85
|
|
|
72
86
|
const LIB_PATH = path.join(
|