@nestia/core 1.6.3 → 1.6.4-dev.20230817

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.
@@ -0,0 +1,39 @@
1
+ import "reflect-metadata";
2
+ /**
3
+ * > You must configure the generic argument `T`
4
+ *
5
+ * Exception decorator.
6
+ *
7
+ * `TypedException` is a decorator function describing HTTP exception and its type
8
+ * which could be occured in the method.
9
+ *
10
+ * For reference, this decorator function does not affect to the method's behavior,
11
+ * but only affects to the swagger documents generation. Also, it does not affect to
12
+ * the SDK library generation yet, but will be used in the future.
13
+ *
14
+ * @param status Status number or pattern like "2xx", "3xx", "4xx", "5xx"
15
+ * @param description Description about the exception
16
+ * @returns Method decorator
17
+ *
18
+ * @author Jeongho Nam - https://github.com/samchon
19
+ * @deprecated
20
+ */
21
+ export declare function TypedException(status: number | "2xx" | "3xx" | "4xx" | "5xx", description?: string | undefined): never;
22
+ /**
23
+ * Exception decorator.
24
+ *
25
+ * `TypedException` is a decorator function describing HTTP exception and its type
26
+ * which could be occured in the method.
27
+ *
28
+ * For reference, this decorator function does not affect to the method's behavior,
29
+ * but only affects to the swagger documents generation. Also, it does not affect to
30
+ * the SDK library generation yet, but will be used in the future.
31
+ *
32
+ * @template T Type of the exception
33
+ * @param status Status number or pattern like "2xx", "3xx", "4xx", "5xx"
34
+ * @param description Description about the exception
35
+ * @returns Method decorator
36
+ *
37
+ * @author Jeongho Nam - https://github.com/samchon
38
+ */
39
+ export declare function TypedException<T extends object>(status: number | "2xx" | "3xx" | "4xx" | "5xx", description?: string | undefined): MethodDecorator;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypedException = void 0;
4
+ require("reflect-metadata");
5
+ /**
6
+ * @internal
7
+ */
8
+ function TypedException(status, description, type) {
9
+ return function TypedException(target, propertyKey, descriptor) {
10
+ var array = (function () {
11
+ var oldbie = Reflect.getMetadata("swagger/TypedException", target[propertyKey]);
12
+ if (oldbie !== undefined)
13
+ return oldbie;
14
+ var newbie = [];
15
+ Reflect.defineMetadata("swagger/TypedException", newbie, target[propertyKey]);
16
+ return newbie;
17
+ })();
18
+ array.push({
19
+ status: status,
20
+ description: description,
21
+ type: type,
22
+ });
23
+ return descriptor;
24
+ };
25
+ }
26
+ exports.TypedException = TypedException;
27
+ //# sourceMappingURL=TypedException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedException.js","sourceRoot":"","sources":["../../src/decorators/TypedException.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAgD1B;;GAEG;AACH,SAAgB,cAAc,CAC1B,MAA8C,EAC9C,WAAgC,EAChC,IAAyB;IAEzB,OAAO,SAAS,cAAc,CAC1B,MAAkB,EAClB,WAA4B,EAC5B,UAAwC;QAExC,IAAM,KAAK,GAAa,CAAC;YACrB,IAAM,MAAM,GAAyB,OAAO,CAAC,WAAW,CACpD,wBAAwB,EACvB,MAAc,CAAC,WAAW,CAAC,CAC/B,CAAC;YACF,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC;YAExC,IAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,OAAO,CAAC,cAAc,CAClB,wBAAwB,EACxB,MAAM,EACL,MAAc,CAAC,WAAW,CAAC,CAC/B,CAAC;YACF,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,CAAC;QACL,KAAK,CAAC,IAAI,CAAC;YACP,MAAM,QAAA;YACN,WAAW,aAAA;YACX,IAAI,EAAE,IAAK;SACd,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC;AAhCD,wCAgCC"}
package/lib/module.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./decorators/EncryptedRoute";
6
6
  export * from "./utils/ExceptionManager";
7
7
  export * from "./decorators/PlainBody";
8
8
  export * from "./decorators/TypedBody";
9
+ export * from "./decorators/TypedException";
9
10
  export * from "./decorators/TypedHeaders";
10
11
  export * from "./decorators/TypedParam";
11
12
  export * from "./decorators/TypedRoute";
package/lib/module.js CHANGED
@@ -22,6 +22,7 @@ __exportStar(require("./decorators/EncryptedRoute"), exports);
22
22
  __exportStar(require("./utils/ExceptionManager"), exports);
23
23
  __exportStar(require("./decorators/PlainBody"), exports);
24
24
  __exportStar(require("./decorators/TypedBody"), exports);
25
+ __exportStar(require("./decorators/TypedException"), exports);
25
26
  __exportStar(require("./decorators/TypedHeaders"), exports);
26
27
  __exportStar(require("./decorators/TypedParam"), exports);
27
28
  __exportStar(require("./decorators/TypedRoute"), exports);
package/lib/module.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,6DAA2C;AAC3C,mEAAiD;AACjD,+DAA6C;AAC7C,8DAA4C;AAC5C,2DAAyC;AACzC,yDAAuC;AACvC,yDAAuC;AACvC,4DAA0C;AAC1C,0DAAwC;AACxC,0DAAwC;AACxC,0DAAwC;AACxC,oEAAkD"}
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,6DAA2C;AAC3C,mEAAiD;AACjD,+DAA6C;AAC7C,8DAA4C;AAC5C,2DAAyC;AACzC,yDAAuC;AACvC,yDAAuC;AACvC,8DAA4C;AAC5C,4DAA0C;AAC1C,0DAAwC;AACxC,0DAAwC;AACxC,0DAAwC;AACxC,oEAAkD"}
@@ -0,0 +1,5 @@
1
+ import ts from "typescript";
2
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
3
+ export declare namespace TypedExceptionProgrammer {
4
+ const generate: ({ checker }: INestiaTransformProject) => (expression: ts.CallExpression) => ts.CallExpression;
5
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TypedExceptionProgrammer = void 0;
7
+ var typescript_1 = __importDefault(require("typescript"));
8
+ var TypedExceptionProgrammer;
9
+ (function (TypedExceptionProgrammer) {
10
+ TypedExceptionProgrammer.generate = function (_a) {
11
+ var checker = _a.checker;
12
+ return function (expression) {
13
+ var _a, _b;
14
+ // CHECK GENERIC ARGUMENT EXISTENCE
15
+ if (!((_a = expression.typeArguments) === null || _a === void 0 ? void 0 : _a[0]))
16
+ throw new Error(NOT_SPECIFIED);
17
+ // GET TYPE INFO
18
+ var node = expression.typeArguments[0];
19
+ var type = checker.getTypeFromTypeNode(node);
20
+ if (type.isTypeParameter())
21
+ throw new Error(NO_GENERIC_ARGUMENT);
22
+ // CHECK DUPLICATED TRNASFORMATION
23
+ if (expression.arguments.length === 3)
24
+ return expression;
25
+ // DO TRANSFORM
26
+ var name = node.getFullText().trim();
27
+ return typescript_1.default.factory.updateCallExpression(expression, expression.expression, expression.typeArguments, [
28
+ expression.arguments[0],
29
+ (_b = expression.arguments[1]) !== null && _b !== void 0 ? _b : typescript_1.default.factory.createIdentifier("undefined"),
30
+ typescript_1.default.factory.createStringLiteral(name),
31
+ ]);
32
+ };
33
+ };
34
+ })(TypedExceptionProgrammer || (exports.TypedExceptionProgrammer = TypedExceptionProgrammer = {}));
35
+ var NOT_SPECIFIED = "Error on @nestia.core.TypedException(): generic argument is not specified.";
36
+ var NO_GENERIC_ARGUMENT = "Error on @nestia.core.TypedException(): non-specified generic argument.";
37
+ //# sourceMappingURL=TypedExceptionProgrammer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedExceptionProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedExceptionProgrammer.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAI5B,IAAiB,wBAAwB,CA8BxC;AA9BD,WAAiB,wBAAwB;IACxB,iCAAQ,GACjB,UAAC,EAAoC;YAAlC,OAAO,aAAA;QACV,OAAA,UAAC,UAA6B;;YAC1B,mCAAmC;YACnC,IAAI,CAAC,CAAA,MAAA,UAAU,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAA;gBAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;YAEnE,gBAAgB;YAChB,IAAM,IAAI,GAAgB,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YACtD,IAAM,IAAI,GAAY,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAExD,IAAI,IAAI,CAAC,eAAe,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAEjE,kCAAkC;YAClC,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,UAAU,CAAC;YAEzD,eAAe;YACf,IAAM,IAAI,GAAW,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;YAC/C,OAAO,oBAAE,CAAC,OAAO,CAAC,oBAAoB,CAClC,UAAU,EACV,UAAU,CAAC,UAAU,EACrB,UAAU,CAAC,aAAa,EACxB;gBACI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;gBACvB,MAAA,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,mCACnB,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC;gBAC5C,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC;aACvC,CACJ,CAAC;QACN,CAAC;IA1BD,CA0BC,CAAC;AACV,CAAC,EA9BgB,wBAAwB,wCAAxB,wBAAwB,QA8BxC;AAED,IAAM,aAAa,GACf,4EAA4E,CAAC;AACjF,IAAM,mBAAmB,GACrB,yEAAyE,CAAC"}
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MethodTransformer = void 0;
7
7
  var typescript_1 = __importDefault(require("typescript"));
8
- var MethodDecoratorTransformer_1 = require("./MethodDecoratorTransformer");
8
+ var TypedExceptionTransformer_1 = require("./TypedExceptionTransformer");
9
+ var TypedRouteTransformer_1 = require("./TypedRouteTransformer");
9
10
  var MethodTransformer;
10
11
  (function (MethodTransformer) {
11
12
  MethodTransformer.transform = function (project) {
@@ -21,16 +22,17 @@ var MethodTransformer;
21
22
  var escaped = original && get_escaped_type(project.checker)(original);
22
23
  if (escaped === undefined)
23
24
  return method;
25
+ var operator = function (deco) {
26
+ deco = TypedExceptionTransformer_1.TypedExceptionTransformer.transform(project)(deco);
27
+ deco = TypedRouteTransformer_1.TypedRouteTransformer.transform(project)(escaped)(deco);
28
+ return deco;
29
+ };
24
30
  if (typescript_1.default.getDecorators !== undefined)
25
31
  return typescript_1.default.factory.updateMethodDeclaration(method, (method.modifiers || []).map(function (mod) {
26
- return typescript_1.default.isDecorator(mod)
27
- ? MethodDecoratorTransformer_1.MethodDecoratorTransformer.transform(project)(escaped)(mod)
28
- : mod;
32
+ return typescript_1.default.isDecorator(mod) ? operator(mod) : mod;
29
33
  }), method.asteriskToken, method.name, method.questionToken, method.typeParameters, method.parameters, method.type, method.body);
30
34
  // eslint-disable-next-line
31
- return typescript_1.default.factory.updateMethodDeclaration(method, decorators.map(function (deco) {
32
- return MethodDecoratorTransformer_1.MethodDecoratorTransformer.transform(project)(escaped)(deco);
33
- }), method.modifiers, method.asteriskToken, method.name, method.questionToken, method.typeParameters, method.parameters, method.type, method.body);
35
+ return typescript_1.default.factory.updateMethodDeclaration(method, decorators.map(operator), method.modifiers, method.asteriskToken, method.name, method.questionToken, method.typeParameters, method.parameters, method.type, method.body);
34
36
  };
35
37
  };
36
38
  })(MethodTransformer || (exports.MethodTransformer = MethodTransformer = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"MethodTransformer.js","sourceRoot":"","sources":["../../src/transformers/MethodTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAG5B,2EAA0E;AAE1E,IAAiB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,SAAS,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC;QACzC,OAAO,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,KAAK,SAAS;YAC3C,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;YAC/B,CAAC,CAAC,IAAI,CAAC;IACf,CAAC;AAND,CAMC,CAAC;AAEN,IAAM,cAAc,GAChB,UAAC,OAAuB;IACxB,OAAA,UAAC,IAAa;QACV,IAAM,OAAO,GAAuB,OAAO,CAAC,gBAAgB,CACxD,IAAwB,CAC3B,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YACpB,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;QACN,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;AATD,CASC,CAAC;AAEN,IAAM,QAAQ,GAAG,UAAC,MAAiB;IAC/B,OAAA,YAAY,CAAC,MAAM,CAAC,eAAe,EAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAC7C,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,CAChC;AAFD,CAEC,CAAC;AAEN,IAAM,YAAY,GACd,UAAC,IAAa;IACd,OAAA,UAAC,IAAY;QACT,OAAA,oBAAE,CAAC,aAAa,CAAC,IAAI,CAAC;YAClB,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAC5B,UAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,cAAI,IAAI,CAAE,CACrD;YACH,CAAC,CAAC,IAAI;IAJV,CAIU;AALd,CAKc,CAAC"}
@@ -0,0 +1,5 @@
1
+ import ts from "typescript";
2
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
3
+ export declare namespace TypedExceptionTransformer {
4
+ const transform: (project: INestiaTransformProject) => (decorator: ts.Decorator) => ts.Decorator;
5
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TypedExceptionTransformer = void 0;
7
+ var path_1 = __importDefault(require("path"));
8
+ var typescript_1 = __importDefault(require("typescript"));
9
+ var TypedExceptionProgrammer_1 = require("../programmers/TypedExceptionProgrammer");
10
+ var TypedExceptionTransformer;
11
+ (function (TypedExceptionTransformer) {
12
+ TypedExceptionTransformer.transform = function (project) {
13
+ return function (decorator) {
14
+ if (!typescript_1.default.isCallExpression(decorator.expression))
15
+ return decorator;
16
+ // CHECK SIGNATURE
17
+ var signature = project.checker.getResolvedSignature(decorator.expression);
18
+ if (!signature || !signature.declaration)
19
+ return decorator;
20
+ // CHECK TO BE TRANSFORMED
21
+ var done = (function () {
22
+ // CHECK FILENAME
23
+ var location = path_1.default.resolve(signature.declaration.getSourceFile().fileName);
24
+ if (location.indexOf(LIB_PATH) === -1 && location !== SRC_PATH)
25
+ return false;
26
+ // CHECK DUPLICATED
27
+ return decorator.expression.arguments.length !== 3;
28
+ })();
29
+ if (done === false)
30
+ return decorator;
31
+ // DO TRANSFORM
32
+ return typescript_1.default.factory.createDecorator(TypedExceptionProgrammer_1.TypedExceptionProgrammer.generate(project)(decorator.expression));
33
+ };
34
+ };
35
+ var LIB_PATH = path_1.default.join("node_modules", "@nestia", "core", "lib", "decorators", "TypedException.d.ts");
36
+ var SRC_PATH = path_1.default.resolve(path_1.default.join(__dirname, "..", "decorators", "TypedException.ts"));
37
+ })(TypedExceptionTransformer || (exports.TypedExceptionTransformer = TypedExceptionTransformer = {}));
38
+ //# sourceMappingURL=TypedExceptionTransformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedExceptionTransformer.js","sourceRoot":"","sources":["../../src/transformers/TypedExceptionTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwB;AACxB,0DAA4B;AAG5B,oFAAmF;AAEnF,I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S,EAAE,IAAI,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAChE,CAAC;AACN,CAAC,EA5CgB,yBAAyB,yCAAzB,yBAAyB,QA4CzC"}
@@ -1,5 +1,5 @@
1
1
  import ts from "typescript";
2
2
  import { INestiaTransformProject } from "../options/INestiaTransformProject";
3
- export declare namespace MethodDecoratorTransformer {
3
+ export declare namespace TypedRouteTransformer {
4
4
  const transform: (project: INestiaTransformProject) => (type: ts.Type) => (decorator: ts.Decorator) => ts.Decorator;
5
5
  }
@@ -28,13 +28,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  return (mod && mod.__esModule) ? mod : { "default": mod };
29
29
  };
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.MethodDecoratorTransformer = void 0;
31
+ exports.TypedRouteTransformer = void 0;
32
32
  var path_1 = __importDefault(require("path"));
33
33
  var typescript_1 = __importDefault(require("typescript"));
34
34
  var TypedRouteProgrammer_1 = require("../programmers/TypedRouteProgrammer");
35
- var MethodDecoratorTransformer;
36
- (function (MethodDecoratorTransformer) {
37
- MethodDecoratorTransformer.transform = function (project) {
35
+ var TypedRouteTransformer;
36
+ (function (TypedRouteTransformer) {
37
+ TypedRouteTransformer.transform = function (project) {
38
38
  return function (type) {
39
39
  return function (decorator) {
40
40
  if (!typescript_1.default.isCallExpression(decorator.expression))
@@ -89,5 +89,5 @@ var MethodDecoratorTransformer;
89
89
  var SRC_PATHS = CLASSES.map(function (cla) {
90
90
  return path_1.default.resolve(path_1.default.join(__dirname, "..", "decorators", "".concat(cla, ".ts")));
91
91
  });
92
- })(MethodDecoratorTransformer || (exports.MethodDecoratorTransformer = MethodDecoratorTransformer = {}));
93
- //# sourceMappingURL=MethodDecoratorTransformer.js.map
92
+ })(TypedRouteTransformer || (exports.TypedRouteTransformer = TypedRouteTransformer = {}));
93
+ //# sourceMappingURL=TypedRouteTransformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedRouteTransformer.js","sourceRoot":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,CAAC,IAAI,CAAC;QAHvC,CAGuC;IAJ3C,CAI2C,CAAC;IAEhD,IAAM,OAAO,GAAG,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IACjD,IAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAC,GAAG;QAC9B,OAAA,cAAI,CAAC,IAAI,CACL,cAAc,EACd,SAAS,EACT,MAAM,EACN,KAAK,EACL,YAAY,EACZ,UAAG,GAAG,UAAO,CAChB;IAPD,CAOC,CACJ,CAAC;IACF,IAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAC,GAAG;QAC9B,OAAA,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,UAAG,GAAG,QAAK,CAAC,CAAC;IAAnE,CAAmE,CACtE,CAAC;AACN,CAAC,EAlFgB,qBAAqB,qCAArB,qBAAqB,QAkFrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/core",
3
- "version": "1.6.3",
3
+ "version": "1.6.4-dev.20230817",
4
4
  "description": "Super-fast validation decorators of NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "homepage": "https://nestia.io",
36
36
  "dependencies": {
37
- "@nestia/fetcher": "^1.6.3",
37
+ "@nestia/fetcher": "^1.6.4-dev.20230817",
38
38
  "@nestjs/common": ">= 7.0.1",
39
39
  "@nestjs/core": ">= 7.0.1",
40
40
  "@nestjs/platform-express": ">= 7.0.1",
@@ -44,10 +44,10 @@
44
44
  "raw-body": ">= 2.0.0",
45
45
  "reflect-metadata": ">= 0.1.12",
46
46
  "rxjs": ">= 6.0.0",
47
- "typia": "^4.2.1"
47
+ "typia": "^4.2.3"
48
48
  },
49
49
  "peerDependencies": {
50
- "@nestia/fetcher": ">= 1.6.3",
50
+ "@nestia/fetcher": ">= 1.6.4-dev.20230817",
51
51
  "@nestjs/common": ">= 7.0.1",
52
52
  "@nestjs/core": ">= 7.0.1",
53
53
  "@nestjs/platform-express": ">= 7.0.1",
@@ -56,7 +56,7 @@
56
56
  "reflect-metadata": ">= 0.1.12",
57
57
  "rxjs": ">= 6.0.0",
58
58
  "typescript": ">= 4.8.0",
59
- "typia": ">= 4.2.1"
59
+ "typia": ">= 4.2.3"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@trivago/prettier-plugin-sort-imports": "^4.0.0",
@@ -0,0 +1,90 @@
1
+ import "reflect-metadata";
2
+
3
+ /**
4
+ * > You must configure the generic argument `T`
5
+ *
6
+ * Exception decorator.
7
+ *
8
+ * `TypedException` is a decorator function describing HTTP exception and its type
9
+ * which could be occured in the method.
10
+ *
11
+ * For reference, this decorator function does not affect to the method's behavior,
12
+ * but only affects to the swagger documents generation. Also, it does not affect to
13
+ * the SDK library generation yet, but will be used in the future.
14
+ *
15
+ * @param status Status number or pattern like "2xx", "3xx", "4xx", "5xx"
16
+ * @param description Description about the exception
17
+ * @returns Method decorator
18
+ *
19
+ * @author Jeongho Nam - https://github.com/samchon
20
+ * @deprecated
21
+ */
22
+ export function TypedException(
23
+ status: number | "2xx" | "3xx" | "4xx" | "5xx",
24
+ description?: string | undefined,
25
+ ): never;
26
+
27
+ /**
28
+ * Exception decorator.
29
+ *
30
+ * `TypedException` is a decorator function describing HTTP exception and its type
31
+ * which could be occured in the method.
32
+ *
33
+ * For reference, this decorator function does not affect to the method's behavior,
34
+ * but only affects to the swagger documents generation. Also, it does not affect to
35
+ * the SDK library generation yet, but will be used in the future.
36
+ *
37
+ * @template T Type of the exception
38
+ * @param status Status number or pattern like "2xx", "3xx", "4xx", "5xx"
39
+ * @param description Description about the exception
40
+ * @returns Method decorator
41
+ *
42
+ * @author Jeongho Nam - https://github.com/samchon
43
+ */
44
+ export function TypedException<T extends object>(
45
+ status: number | "2xx" | "3xx" | "4xx" | "5xx",
46
+ description?: string | undefined,
47
+ ): MethodDecorator;
48
+
49
+ /**
50
+ * @internal
51
+ */
52
+ export function TypedException<T extends object>(
53
+ status: number | "2xx" | "3xx" | "4xx" | "5xx",
54
+ description?: string | undefined,
55
+ type?: string | undefined,
56
+ ): MethodDecorator {
57
+ return function TypedException(
58
+ target: Object | T,
59
+ propertyKey: string | symbol,
60
+ descriptor: TypedPropertyDescriptor<any>,
61
+ ) {
62
+ const array: IProps[] = (() => {
63
+ const oldbie: IProps[] | undefined = Reflect.getMetadata(
64
+ `swagger/TypedException`,
65
+ (target as any)[propertyKey],
66
+ );
67
+ if (oldbie !== undefined) return oldbie;
68
+
69
+ const newbie: IProps[] = [];
70
+ Reflect.defineMetadata(
71
+ `swagger/TypedException`,
72
+ newbie,
73
+ (target as any)[propertyKey],
74
+ );
75
+ return newbie;
76
+ })();
77
+ array.push({
78
+ status,
79
+ description,
80
+ type: type!,
81
+ });
82
+ return descriptor;
83
+ };
84
+ }
85
+
86
+ interface IProps {
87
+ status: number | "2xx" | "3xx" | "4xx" | "5xx";
88
+ description?: string | undefined;
89
+ type: string;
90
+ }
package/src/module.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./decorators/EncryptedRoute";
6
6
  export * from "./utils/ExceptionManager";
7
7
  export * from "./decorators/PlainBody";
8
8
  export * from "./decorators/TypedBody";
9
+ export * from "./decorators/TypedException";
9
10
  export * from "./decorators/TypedHeaders";
10
11
  export * from "./decorators/TypedParam";
11
12
  export * from "./decorators/TypedRoute";
@@ -0,0 +1,40 @@
1
+ import ts from "typescript";
2
+
3
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
4
+
5
+ export namespace TypedExceptionProgrammer {
6
+ export const generate =
7
+ ({ checker }: INestiaTransformProject) =>
8
+ (expression: ts.CallExpression): ts.CallExpression => {
9
+ // CHECK GENERIC ARGUMENT EXISTENCE
10
+ if (!expression.typeArguments?.[0]) throw new Error(NOT_SPECIFIED);
11
+
12
+ // GET TYPE INFO
13
+ const node: ts.TypeNode = expression.typeArguments[0];
14
+ const type: ts.Type = checker.getTypeFromTypeNode(node);
15
+
16
+ if (type.isTypeParameter()) throw new Error(NO_GENERIC_ARGUMENT);
17
+
18
+ // CHECK DUPLICATED TRNASFORMATION
19
+ if (expression.arguments.length === 3) return expression;
20
+
21
+ // DO TRANSFORM
22
+ const name: string = node.getFullText().trim();
23
+ return ts.factory.updateCallExpression(
24
+ expression,
25
+ expression.expression,
26
+ expression.typeArguments,
27
+ [
28
+ expression.arguments[0],
29
+ expression.arguments[1] ??
30
+ ts.factory.createIdentifier("undefined"),
31
+ ts.factory.createStringLiteral(name),
32
+ ],
33
+ );
34
+ };
35
+ }
36
+
37
+ const NOT_SPECIFIED =
38
+ "Error on @nestia.core.TypedException(): generic argument is not specified.";
39
+ const NO_GENERIC_ARGUMENT =
40
+ "Error on @nestia.core.TypedException(): non-specified generic argument.";
@@ -1,7 +1,8 @@
1
1
  import ts from "typescript";
2
2
 
3
3
  import { INestiaTransformProject } from "../options/INestiaTransformProject";
4
- import { MethodDecoratorTransformer } from "./MethodDecoratorTransformer";
4
+ import { TypedExceptionTransformer } from "./TypedExceptionTransformer";
5
+ import { TypedRouteTransformer } from "./TypedRouteTransformer";
5
6
 
6
7
  export namespace MethodTransformer {
7
8
  export const transform =
@@ -23,15 +24,16 @@ export namespace MethodTransformer {
23
24
 
24
25
  if (escaped === undefined) return method;
25
26
 
27
+ const operator = (deco: ts.Decorator): ts.Decorator => {
28
+ deco = TypedExceptionTransformer.transform(project)(deco);
29
+ deco = TypedRouteTransformer.transform(project)(escaped)(deco);
30
+ return deco;
31
+ };
26
32
  if (ts.getDecorators !== undefined)
27
33
  return ts.factory.updateMethodDeclaration(
28
34
  method,
29
35
  (method.modifiers || []).map((mod) =>
30
- ts.isDecorator(mod)
31
- ? MethodDecoratorTransformer.transform(project)(
32
- escaped,
33
- )(mod)
34
- : mod,
36
+ ts.isDecorator(mod) ? operator(mod) : mod,
35
37
  ),
36
38
  method.asteriskToken,
37
39
  method.name,
@@ -44,11 +46,7 @@ export namespace MethodTransformer {
44
46
  // eslint-disable-next-line
45
47
  return (ts.factory.updateMethodDeclaration as any)(
46
48
  method,
47
- decorators.map((deco) =>
48
- MethodDecoratorTransformer.transform(project)(escaped)(
49
- deco,
50
- ),
51
- ),
49
+ decorators.map(operator),
52
50
  (method as any).modifiers,
53
51
  method.asteriskToken,
54
52
  method.name,
@@ -0,0 +1,51 @@
1
+ import path from "path";
2
+ import ts from "typescript";
3
+
4
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
5
+ import { TypedExceptionProgrammer } from "../programmers/TypedExceptionProgrammer";
6
+
7
+ export namespace TypedExceptionTransformer {
8
+ export const transform =
9
+ (project: INestiaTransformProject) =>
10
+ (decorator: ts.Decorator): ts.Decorator => {
11
+ if (!ts.isCallExpression(decorator.expression)) return decorator;
12
+
13
+ // CHECK SIGNATURE
14
+ const signature: ts.Signature | undefined =
15
+ project.checker.getResolvedSignature(decorator.expression);
16
+ if (!signature || !signature.declaration) return decorator;
17
+
18
+ // CHECK TO BE TRANSFORMED
19
+ const done: boolean = (() => {
20
+ // CHECK FILENAME
21
+ const location: string = path.resolve(
22
+ signature.declaration.getSourceFile().fileName,
23
+ );
24
+ if (location.indexOf(LIB_PATH) === -1 && location !== SRC_PATH)
25
+ return false;
26
+
27
+ // CHECK DUPLICATED
28
+ return decorator.expression.arguments.length !== 3;
29
+ })();
30
+ if (done === false) return decorator;
31
+
32
+ // DO TRANSFORM
33
+ return ts.factory.createDecorator(
34
+ TypedExceptionProgrammer.generate(project)(
35
+ decorator.expression,
36
+ ),
37
+ );
38
+ };
39
+
40
+ const LIB_PATH = path.join(
41
+ "node_modules",
42
+ "@nestia",
43
+ "core",
44
+ "lib",
45
+ "decorators",
46
+ `TypedException.d.ts`,
47
+ );
48
+ const SRC_PATH = path.resolve(
49
+ path.join(__dirname, "..", "decorators", `TypedException.ts`),
50
+ );
51
+ }
@@ -4,7 +4,7 @@ import ts from "typescript";
4
4
  import { INestiaTransformProject } from "../options/INestiaTransformProject";
5
5
  import { TypedRouteProgrammer } from "../programmers/TypedRouteProgrammer";
6
6
 
7
- export namespace MethodDecoratorTransformer {
7
+ export namespace TypedRouteTransformer {
8
8
  export const transform =
9
9
  (project: INestiaTransformProject) =>
10
10
  (type: ts.Type) =>
@@ -1 +0,0 @@
1
- {"version":3,"file":"MethodDecoratorTransformer.js","sourceRoot":"","sources":["../../src/transformers/MethodDecoratorTransformer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,0DAA4B;AAG5B,4EAA2E;AAE3E,IAAiB,0BAA0B,CAkF1C;AAlFD,WAAiB,0BAA0B;IAC1B,oCAAS,GAClB,UAAC,OAAgC;QACjC,OAAA,UAAC,IAAa;YACd,OAAA,UAAC,SAAuB;gBACpB,IAAI,CAAC,oBAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;oBAAE,OAAO,SAAS,CAAC;gBAEjE,kBAAkB;gBAClB,IAAM,SAAS,GACX,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBAC/D,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,WAAW;oBAAE,OAAO,SAAS,CAAC;gBAE3D,0BAA0B;gBAC1B,IAAM,IAAI,GAAY,CAAC;oBACnB,iBAAiB;oBACjB,IAAM,QAAQ,GAAW,cAAI,CAAC,OAAO,CACjC,SAAS,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,QAAQ,CACjD,CAAC;oBACF,IACI,SAAS,CAAC,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAA5B,CAA4B,CAAC;wBACtD,SAAS,CAAC,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,QAAQ,KAAK,GAAG,EAAhB,CAAgB,CAAC;wBAE1C,OAAO,KAAK,CAAC;oBAEjB,0BAA0B;oBAC1B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