@nestia/core 1.1.1 → 1.1.2-dev.20230503

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.
Files changed (89) hide show
  1. package/lib/decorators/DynamicModule.d.ts +26 -23
  2. package/lib/decorators/DynamicModule.js +103 -103
  3. package/lib/decorators/DynamicModule.js.map +1 -1
  4. package/lib/decorators/EncryptedBody.d.ts +23 -23
  5. package/lib/decorators/EncryptedBody.js +125 -125
  6. package/lib/decorators/EncryptedController.d.ts +31 -31
  7. package/lib/decorators/EncryptedController.js +41 -41
  8. package/lib/decorators/EncryptedModule.d.ts +52 -49
  9. package/lib/decorators/EncryptedModule.js +161 -161
  10. package/lib/decorators/EncryptedModule.js.map +1 -1
  11. package/lib/decorators/EncryptedRoute.d.ts +78 -78
  12. package/lib/decorators/EncryptedRoute.js +216 -216
  13. package/lib/decorators/PlainBody.d.ts +22 -22
  14. package/lib/decorators/PlainBody.js +82 -82
  15. package/lib/decorators/TypedBody.d.ts +16 -16
  16. package/lib/decorators/TypedBody.js +94 -94
  17. package/lib/decorators/TypedParam.d.ts +31 -31
  18. package/lib/decorators/TypedParam.js +68 -65
  19. package/lib/decorators/TypedParam.js.map +1 -1
  20. package/lib/decorators/TypedQuery.d.ts +14 -14
  21. package/lib/decorators/TypedQuery.js +124 -124
  22. package/lib/decorators/TypedRoute.d.ts +72 -72
  23. package/lib/decorators/TypedRoute.js +185 -185
  24. package/lib/decorators/internal/EncryptedConstant.d.ts +1 -1
  25. package/lib/decorators/internal/EncryptedConstant.js +7 -7
  26. package/lib/decorators/internal/TransformError.d.ts +1 -1
  27. package/lib/decorators/internal/TransformError.js +10 -10
  28. package/lib/decorators/internal/TransformError.js.map +1 -1
  29. package/lib/decorators/internal/get_path_and_stringify.d.ts +1 -1
  30. package/lib/decorators/internal/get_path_and_stringify.js +78 -78
  31. package/lib/decorators/internal/headers_to_object.d.ts +3 -3
  32. package/lib/decorators/internal/headers_to_object.js +49 -49
  33. package/lib/decorators/internal/load_controller.d.ts +5 -2
  34. package/lib/decorators/internal/load_controller.js +152 -151
  35. package/lib/decorators/internal/load_controller.js.map +1 -1
  36. package/lib/decorators/internal/route_error.d.ts +2 -2
  37. package/lib/decorators/internal/route_error.js +86 -86
  38. package/lib/decorators/internal/validate_request_body.d.ts +2 -2
  39. package/lib/decorators/internal/validate_request_body.js +57 -57
  40. package/lib/index.d.ts +3 -3
  41. package/lib/index.js +31 -31
  42. package/lib/module.d.ts +12 -12
  43. package/lib/module.js +28 -28
  44. package/lib/options/INestiaTransformOptions.d.ts +4 -4
  45. package/lib/options/INestiaTransformOptions.js +2 -2
  46. package/lib/options/INestiaTransformProject.d.ts +5 -5
  47. package/lib/options/INestiaTransformProject.js +2 -2
  48. package/lib/options/IRequestBodyValidator.d.ts +16 -16
  49. package/lib/options/IRequestBodyValidator.js +2 -2
  50. package/lib/options/IResponseBodyStringifier.d.ts +20 -20
  51. package/lib/options/IResponseBodyStringifier.js +2 -2
  52. package/lib/programmers/TypedBodyProgrammer.d.ts +5 -5
  53. package/lib/programmers/TypedBodyProgrammer.js +47 -47
  54. package/lib/programmers/TypedParamProgrammer.d.ts +5 -5
  55. package/lib/programmers/TypedParamProgrammer.js +107 -107
  56. package/lib/programmers/TypedQueryProgrammer.d.ts +5 -5
  57. package/lib/programmers/TypedQueryProgrammer.js +263 -263
  58. package/lib/programmers/TypedRouteProgrammer.d.ts +5 -5
  59. package/lib/programmers/TypedRouteProgrammer.js +49 -49
  60. package/lib/transform.d.ts +3 -3
  61. package/lib/transform.js +20 -20
  62. package/lib/transformers/FileTransformer.d.ts +5 -5
  63. package/lib/transformers/FileTransformer.js +32 -32
  64. package/lib/transformers/MethodDecoratorTransformer.d.ts +5 -5
  65. package/lib/transformers/MethodDecoratorTransformer.js +87 -87
  66. package/lib/transformers/MethodTransformer.d.ts +5 -5
  67. package/lib/transformers/MethodTransformer.js +54 -54
  68. package/lib/transformers/NodeTransformer.d.ts +5 -5
  69. package/lib/transformers/NodeTransformer.js +20 -20
  70. package/lib/transformers/ParameterDecoratorTransformer.d.ts +5 -5
  71. package/lib/transformers/ParameterDecoratorTransformer.js +65 -65
  72. package/lib/transformers/ParameterTransformer.d.ts +5 -5
  73. package/lib/transformers/ParameterTransformer.js +33 -33
  74. package/lib/typings/Creator.d.ts +3 -3
  75. package/lib/typings/Creator.js +2 -2
  76. package/lib/utils/ExceptionManager.d.ts +64 -64
  77. package/lib/utils/ExceptionManager.js +112 -112
  78. package/lib/utils/Singleton.d.ts +1 -1
  79. package/lib/utils/Singleton.js +23 -23
  80. package/lib/utils/SourceFinder.d.ts +9 -0
  81. package/lib/utils/SourceFinder.js +239 -0
  82. package/lib/utils/SourceFinder.js.map +1 -0
  83. package/package.json +7 -7
  84. package/src/decorators/DynamicModule.ts +1 -1
  85. package/src/decorators/EncryptedModule.ts +1 -1
  86. package/src/decorators/TypedParam.ts +4 -1
  87. package/src/decorators/internal/TransformError.ts +1 -1
  88. package/src/decorators/internal/load_controller.ts +32 -25
  89. package/src/utils/SourceFinder.ts +60 -0
@@ -1,66 +1,66 @@
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.ParameterDecoratorTransformer = void 0;
7
- var path_1 = __importDefault(require("path"));
8
- var typescript_1 = __importDefault(require("typescript"));
9
- var TypedBodyProgrammer_1 = require("../programmers/TypedBodyProgrammer");
10
- var TypedParamProgrammer_1 = require("../programmers/TypedParamProgrammer");
11
- var TypedQueryProgrammer_1 = require("../programmers/TypedQueryProgrammer");
12
- var ParameterDecoratorTransformer;
13
- (function (ParameterDecoratorTransformer) {
14
- function transform(project, type, decorator) {
15
- var _a;
16
- //----
17
- // VALIDATIONS
18
- //----
19
- // CHECK DECORATOR
20
- if (!typescript_1.default.isCallExpression(decorator.expression))
21
- return decorator;
22
- // SIGNATURE DECLARATION
23
- var declaration = (_a = project.checker.getResolvedSignature(decorator.expression)) === null || _a === void 0 ? void 0 : _a.declaration;
24
- if (declaration === undefined)
25
- return decorator;
26
- // FILE PATH
27
- var file = path_1.default.resolve(declaration.getSourceFile().fileName);
28
- if (file.indexOf(LIB_PATH) === -1 && file.indexOf(SRC_PATH) === -1)
29
- return decorator;
30
- //----
31
- // TRANSFORMATION
32
- //----
33
- // FIND PROGRAMMER
34
- var programmer = FUNCTORS[project.checker.getTypeAtLocation(declaration).symbol.name];
35
- if (programmer === undefined)
36
- return decorator;
37
- // GET TYPE INFO
38
- var typeNode = project.checker.typeToTypeNode(type, undefined, undefined);
39
- if (typeNode === undefined)
40
- return decorator;
41
- // DO TRANSFORM
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)));
43
- }
44
- ParameterDecoratorTransformer.transform = transform;
45
- })(ParameterDecoratorTransformer = exports.ParameterDecoratorTransformer || (exports.ParameterDecoratorTransformer = {}));
46
- var FUNCTORS = {
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
- }; }; },
63
- };
64
- var LIB_PATH = path_1.default.join("node_modules", "@nestia", "core", "lib", "decorators");
65
- var SRC_PATH = path_1.default.resolve(path_1.default.join(__dirname, "..", "decorators"));
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.ParameterDecoratorTransformer = void 0;
7
+ var path_1 = __importDefault(require("path"));
8
+ var typescript_1 = __importDefault(require("typescript"));
9
+ var TypedBodyProgrammer_1 = require("../programmers/TypedBodyProgrammer");
10
+ var TypedParamProgrammer_1 = require("../programmers/TypedParamProgrammer");
11
+ var TypedQueryProgrammer_1 = require("../programmers/TypedQueryProgrammer");
12
+ var ParameterDecoratorTransformer;
13
+ (function (ParameterDecoratorTransformer) {
14
+ function transform(project, type, decorator) {
15
+ var _a;
16
+ //----
17
+ // VALIDATIONS
18
+ //----
19
+ // CHECK DECORATOR
20
+ if (!typescript_1.default.isCallExpression(decorator.expression))
21
+ return decorator;
22
+ // SIGNATURE DECLARATION
23
+ var declaration = (_a = project.checker.getResolvedSignature(decorator.expression)) === null || _a === void 0 ? void 0 : _a.declaration;
24
+ if (declaration === undefined)
25
+ return decorator;
26
+ // FILE PATH
27
+ var file = path_1.default.resolve(declaration.getSourceFile().fileName);
28
+ if (file.indexOf(LIB_PATH) === -1 && file.indexOf(SRC_PATH) === -1)
29
+ return decorator;
30
+ //----
31
+ // TRANSFORMATION
32
+ //----
33
+ // FIND PROGRAMMER
34
+ var programmer = FUNCTORS[project.checker.getTypeAtLocation(declaration).symbol.name];
35
+ if (programmer === undefined)
36
+ return decorator;
37
+ // GET TYPE INFO
38
+ var typeNode = project.checker.typeToTypeNode(type, undefined, undefined);
39
+ if (typeNode === undefined)
40
+ return decorator;
41
+ // DO TRANSFORM
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)));
43
+ }
44
+ ParameterDecoratorTransformer.transform = transform;
45
+ })(ParameterDecoratorTransformer = exports.ParameterDecoratorTransformer || (exports.ParameterDecoratorTransformer = {}));
46
+ var FUNCTORS = {
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
+ }; }; },
63
+ };
64
+ var LIB_PATH = path_1.default.join("node_modules", "@nestia", "core", "lib", "decorators");
65
+ var SRC_PATH = path_1.default.resolve(path_1.default.join(__dirname, "..", "decorators"));
66
66
  //# sourceMappingURL=ParameterDecoratorTransformer.js.map
@@ -1,5 +1,5 @@
1
- import ts from "typescript";
2
- import { INestiaTransformProject } from "../options/INestiaTransformProject";
3
- export declare namespace ParameterTransformer {
4
- function transform(project: INestiaTransformProject, param: ts.ParameterDeclaration): ts.ParameterDeclaration;
5
- }
1
+ import ts from "typescript";
2
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
3
+ export declare namespace ParameterTransformer {
4
+ function transform(project: INestiaTransformProject, param: ts.ParameterDeclaration): ts.ParameterDeclaration;
5
+ }
@@ -1,34 +1,34 @@
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.ParameterTransformer = void 0;
7
- var typescript_1 = __importDefault(require("typescript"));
8
- var ParameterDecoratorTransformer_1 = require("./ParameterDecoratorTransformer");
9
- var ParameterTransformer;
10
- (function (ParameterTransformer) {
11
- function transform(project, param) {
12
- // CHECK DECORATOR
13
- var decorators = typescript_1.default.getDecorators
14
- ? typescript_1.default.getDecorators(param)
15
- : param.decorators;
16
- if (!(decorators === null || decorators === void 0 ? void 0 : decorators.length))
17
- return param;
18
- // GET TYPE INFO
19
- var type = project.checker.getTypeAtLocation(param);
20
- // WHEN LATEST TS VERSION
21
- if (typescript_1.default.getDecorators !== undefined)
22
- return typescript_1.default.factory.updateParameterDeclaration(param, (param.modifiers || []).map(function (mod) {
23
- return typescript_1.default.isDecorator(mod)
24
- ? ParameterDecoratorTransformer_1.ParameterDecoratorTransformer.transform(project, type, mod)
25
- : mod;
26
- }), param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
27
- // eslint-disable-next-line
28
- return typescript_1.default.factory.updateParameterDeclaration(param, decorators.map(function (deco) {
29
- return ParameterDecoratorTransformer_1.ParameterDecoratorTransformer.transform(project, type, deco);
30
- }), param.modifiers, param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
31
- }
32
- ParameterTransformer.transform = transform;
33
- })(ParameterTransformer = exports.ParameterTransformer || (exports.ParameterTransformer = {}));
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.ParameterTransformer = void 0;
7
+ var typescript_1 = __importDefault(require("typescript"));
8
+ var ParameterDecoratorTransformer_1 = require("./ParameterDecoratorTransformer");
9
+ var ParameterTransformer;
10
+ (function (ParameterTransformer) {
11
+ function transform(project, param) {
12
+ // CHECK DECORATOR
13
+ var decorators = typescript_1.default.getDecorators
14
+ ? typescript_1.default.getDecorators(param)
15
+ : param.decorators;
16
+ if (!(decorators === null || decorators === void 0 ? void 0 : decorators.length))
17
+ return param;
18
+ // GET TYPE INFO
19
+ var type = project.checker.getTypeAtLocation(param);
20
+ // WHEN LATEST TS VERSION
21
+ if (typescript_1.default.getDecorators !== undefined)
22
+ return typescript_1.default.factory.updateParameterDeclaration(param, (param.modifiers || []).map(function (mod) {
23
+ return typescript_1.default.isDecorator(mod)
24
+ ? ParameterDecoratorTransformer_1.ParameterDecoratorTransformer.transform(project, type, mod)
25
+ : mod;
26
+ }), param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
27
+ // eslint-disable-next-line
28
+ return typescript_1.default.factory.updateParameterDeclaration(param, decorators.map(function (deco) {
29
+ return ParameterDecoratorTransformer_1.ParameterDecoratorTransformer.transform(project, type, deco);
30
+ }), param.modifiers, param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
31
+ }
32
+ ParameterTransformer.transform = transform;
33
+ })(ParameterTransformer = exports.ParameterTransformer || (exports.ParameterTransformer = {}));
34
34
  //# sourceMappingURL=ParameterTransformer.js.map
@@ -1,3 +1,3 @@
1
- export type Creator<T extends object> = {
2
- new (...args: any[]): T;
3
- };
1
+ export type Creator<T extends object> = {
2
+ new (...args: any[]): T;
3
+ };
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=Creator.js.map
@@ -1,64 +1,64 @@
1
- import { HttpException } from "@nestjs/common";
2
- import { Creator } from "../typings/Creator";
3
- /**
4
- * Exception manager for HTTP server.
5
- *
6
- * `ExceptionManager` is an utility class who can insert or erase custom error class with
7
- * its convertion method to a regular {@link nest.HttpException} instance.
8
- *
9
- * If you define an API function through {@link TypedRoute} or {@link EncryptedRoute}
10
- * instead of the basic router decorator functions like {@link nest.Get} or
11
- * {@link nest.Post} and the API function throws a custom error whose class has been
12
- * {@link ExceptionManager.insert inserted} in this `EntityManager`, the error would be
13
- * automatically converted to the regular {@link nest.HttpException} instance by the
14
- * {@link ExceptionManager.Closure} function.
15
- *
16
- * Therefore, with this `ExceptionManager` and {@link TypedRoute} or {@link EncryptedRoute},
17
- * you can manage your custom error classes much systemtically. You can avoid 500 internal
18
- * server error or hard coding implementation about the custom error classes.
19
- *
20
- * Below error classes are defaultly configured in this `ExceptionManager`
21
- *
22
- * - `typia.TypeGuardError`
23
- * - `@nestia/fetcher.HttpError`
24
- *
25
- * @author Jeongho Nam - https://github.com/samchon
26
- */
27
- export declare namespace ExceptionManager {
28
- /**
29
- * Insert an error class with converter.
30
- *
31
- * If you've inserted an duplicated error class, the closure would be overwritten.
32
- *
33
- * @param creator Target error class
34
- * @param closure A closure function converting to the `HttpException` class
35
- */
36
- function insert<T extends Error>(creator: Creator<T>, closure: Closure<T>): void;
37
- /**
38
- * Erase an error class.
39
- *
40
- * @param creator Target error class
41
- * @returns Whether be erased or not
42
- */
43
- function erase<T extends Error>(creator: Creator<T>): boolean;
44
- function on(closure: (error: any) => any): void;
45
- function off(closure: (error: any) => any): void;
46
- /**
47
- * Type of a closure function converting to the regular {@link nest.HttpException}.
48
- *
49
- * `ExceptionManager.Closure` is a type of closure function who are converting from
50
- * custom error to the regular {@link nest.HttpException} instance. It would be used
51
- * in the {@link ExceptionManager} with {@link TypedRoute} or {@link EncryptedRoute}.
52
- */
53
- interface Closure<T extends Error> {
54
- /**
55
- * Error converter.
56
- *
57
- * Convert from custom error to the regular {@link nest.HttpException} instance.
58
- *
59
- * @param exception Custom error instance
60
- * @return Regular {@link nest.HttpException} instance
61
- */
62
- (exception: T): HttpException;
63
- }
64
- }
1
+ import { HttpException } from "@nestjs/common";
2
+ import { Creator } from "../typings/Creator";
3
+ /**
4
+ * Exception manager for HTTP server.
5
+ *
6
+ * `ExceptionManager` is an utility class who can insert or erase custom error class with
7
+ * its convertion method to a regular {@link nest.HttpException} instance.
8
+ *
9
+ * If you define an API function through {@link TypedRoute} or {@link EncryptedRoute}
10
+ * instead of the basic router decorator functions like {@link nest.Get} or
11
+ * {@link nest.Post} and the API function throws a custom error whose class has been
12
+ * {@link ExceptionManager.insert inserted} in this `EntityManager`, the error would be
13
+ * automatically converted to the regular {@link nest.HttpException} instance by the
14
+ * {@link ExceptionManager.Closure} function.
15
+ *
16
+ * Therefore, with this `ExceptionManager` and {@link TypedRoute} or {@link EncryptedRoute},
17
+ * you can manage your custom error classes much systemtically. You can avoid 500 internal
18
+ * server error or hard coding implementation about the custom error classes.
19
+ *
20
+ * Below error classes are defaultly configured in this `ExceptionManager`
21
+ *
22
+ * - `typia.TypeGuardError`
23
+ * - `@nestia/fetcher.HttpError`
24
+ *
25
+ * @author Jeongho Nam - https://github.com/samchon
26
+ */
27
+ export declare namespace ExceptionManager {
28
+ /**
29
+ * Insert an error class with converter.
30
+ *
31
+ * If you've inserted an duplicated error class, the closure would be overwritten.
32
+ *
33
+ * @param creator Target error class
34
+ * @param closure A closure function converting to the `HttpException` class
35
+ */
36
+ function insert<T extends Error>(creator: Creator<T>, closure: Closure<T>): void;
37
+ /**
38
+ * Erase an error class.
39
+ *
40
+ * @param creator Target error class
41
+ * @returns Whether be erased or not
42
+ */
43
+ function erase<T extends Error>(creator: Creator<T>): boolean;
44
+ function on(closure: (error: any) => any): void;
45
+ function off(closure: (error: any) => any): void;
46
+ /**
47
+ * Type of a closure function converting to the regular {@link nest.HttpException}.
48
+ *
49
+ * `ExceptionManager.Closure` is a type of closure function who are converting from
50
+ * custom error to the regular {@link nest.HttpException} instance. It would be used
51
+ * in the {@link ExceptionManager} with {@link TypedRoute} or {@link EncryptedRoute}.
52
+ */
53
+ interface Closure<T extends Error> {
54
+ /**
55
+ * Error converter.
56
+ *
57
+ * Convert from custom error to the regular {@link nest.HttpException} instance.
58
+ *
59
+ * @param exception Custom error instance
60
+ * @return Regular {@link nest.HttpException} instance
61
+ */
62
+ (exception: T): HttpException;
63
+ }
64
+ }
@@ -1,113 +1,113 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.ExceptionManager = void 0;
20
- var fetcher_1 = require("@nestia/fetcher");
21
- var common_1 = require("@nestjs/common");
22
- var typia_1 = require("typia");
23
- /**
24
- * Exception manager for HTTP server.
25
- *
26
- * `ExceptionManager` is an utility class who can insert or erase custom error class with
27
- * its convertion method to a regular {@link nest.HttpException} instance.
28
- *
29
- * If you define an API function through {@link TypedRoute} or {@link EncryptedRoute}
30
- * instead of the basic router decorator functions like {@link nest.Get} or
31
- * {@link nest.Post} and the API function throws a custom error whose class has been
32
- * {@link ExceptionManager.insert inserted} in this `EntityManager`, the error would be
33
- * automatically converted to the regular {@link nest.HttpException} instance by the
34
- * {@link ExceptionManager.Closure} function.
35
- *
36
- * Therefore, with this `ExceptionManager` and {@link TypedRoute} or {@link EncryptedRoute},
37
- * you can manage your custom error classes much systemtically. You can avoid 500 internal
38
- * server error or hard coding implementation about the custom error classes.
39
- *
40
- * Below error classes are defaultly configured in this `ExceptionManager`
41
- *
42
- * - `typia.TypeGuardError`
43
- * - `@nestia/fetcher.HttpError`
44
- *
45
- * @author Jeongho Nam - https://github.com/samchon
46
- */
47
- var ExceptionManager;
48
- (function (ExceptionManager) {
49
- /**
50
- * Insert an error class with converter.
51
- *
52
- * If you've inserted an duplicated error class, the closure would be overwritten.
53
- *
54
- * @param creator Target error class
55
- * @param closure A closure function converting to the `HttpException` class
56
- */
57
- function insert(creator, closure) {
58
- var index = ExceptionManager.tuples.findIndex(function (tuple) { return tuple[0] === creator; });
59
- if (index !== -1)
60
- ExceptionManager.tuples.splice(index, 1);
61
- ExceptionManager.tuples.push([creator, closure]);
62
- ExceptionManager.tuples.sort(function (_a, _b) {
63
- var _c = __read(_a, 1), x = _c[0];
64
- var _d = __read(_b, 1), y = _d[0];
65
- return (x.prototype instanceof y ? -1 : 1);
66
- });
67
- }
68
- ExceptionManager.insert = insert;
69
- /**
70
- * Erase an error class.
71
- *
72
- * @param creator Target error class
73
- * @returns Whether be erased or not
74
- */
75
- function erase(creator) {
76
- var index = ExceptionManager.tuples.findIndex(function (tuple) { return tuple[0] === creator; });
77
- if (index === -1)
78
- return false;
79
- ExceptionManager.tuples.splice(index, 1);
80
- return true;
81
- }
82
- ExceptionManager.erase = erase;
83
- function on(closure) {
84
- ExceptionManager.listeners.add(closure);
85
- }
86
- ExceptionManager.on = on;
87
- function off(closure) {
88
- ExceptionManager.listeners.delete(closure);
89
- }
90
- ExceptionManager.off = off;
91
- /**
92
- * @internal
93
- */
94
- ExceptionManager.tuples = [];
95
- /**
96
- * @internal
97
- */
98
- ExceptionManager.listeners = new Set();
99
- })(ExceptionManager = exports.ExceptionManager || (exports.ExceptionManager = {}));
100
- ExceptionManager.insert(typia_1.TypeGuardError, function (error) {
101
- return new common_1.HttpException({
102
- path: error.path,
103
- reason: error.message,
104
- message: "Request message is not following the promised type.",
105
- }, 400);
106
- });
107
- ExceptionManager.insert(fetcher_1.HttpError, function (error) {
108
- return new common_1.HttpException({
109
- path: error.path,
110
- message: error.message,
111
- }, error.status);
112
- });
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
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ExceptionManager = void 0;
20
+ var fetcher_1 = require("@nestia/fetcher");
21
+ var common_1 = require("@nestjs/common");
22
+ var typia_1 = require("typia");
23
+ /**
24
+ * Exception manager for HTTP server.
25
+ *
26
+ * `ExceptionManager` is an utility class who can insert or erase custom error class with
27
+ * its convertion method to a regular {@link nest.HttpException} instance.
28
+ *
29
+ * If you define an API function through {@link TypedRoute} or {@link EncryptedRoute}
30
+ * instead of the basic router decorator functions like {@link nest.Get} or
31
+ * {@link nest.Post} and the API function throws a custom error whose class has been
32
+ * {@link ExceptionManager.insert inserted} in this `EntityManager`, the error would be
33
+ * automatically converted to the regular {@link nest.HttpException} instance by the
34
+ * {@link ExceptionManager.Closure} function.
35
+ *
36
+ * Therefore, with this `ExceptionManager` and {@link TypedRoute} or {@link EncryptedRoute},
37
+ * you can manage your custom error classes much systemtically. You can avoid 500 internal
38
+ * server error or hard coding implementation about the custom error classes.
39
+ *
40
+ * Below error classes are defaultly configured in this `ExceptionManager`
41
+ *
42
+ * - `typia.TypeGuardError`
43
+ * - `@nestia/fetcher.HttpError`
44
+ *
45
+ * @author Jeongho Nam - https://github.com/samchon
46
+ */
47
+ var ExceptionManager;
48
+ (function (ExceptionManager) {
49
+ /**
50
+ * Insert an error class with converter.
51
+ *
52
+ * If you've inserted an duplicated error class, the closure would be overwritten.
53
+ *
54
+ * @param creator Target error class
55
+ * @param closure A closure function converting to the `HttpException` class
56
+ */
57
+ function insert(creator, closure) {
58
+ var index = ExceptionManager.tuples.findIndex(function (tuple) { return tuple[0] === creator; });
59
+ if (index !== -1)
60
+ ExceptionManager.tuples.splice(index, 1);
61
+ ExceptionManager.tuples.push([creator, closure]);
62
+ ExceptionManager.tuples.sort(function (_a, _b) {
63
+ var _c = __read(_a, 1), x = _c[0];
64
+ var _d = __read(_b, 1), y = _d[0];
65
+ return (x.prototype instanceof y ? -1 : 1);
66
+ });
67
+ }
68
+ ExceptionManager.insert = insert;
69
+ /**
70
+ * Erase an error class.
71
+ *
72
+ * @param creator Target error class
73
+ * @returns Whether be erased or not
74
+ */
75
+ function erase(creator) {
76
+ var index = ExceptionManager.tuples.findIndex(function (tuple) { return tuple[0] === creator; });
77
+ if (index === -1)
78
+ return false;
79
+ ExceptionManager.tuples.splice(index, 1);
80
+ return true;
81
+ }
82
+ ExceptionManager.erase = erase;
83
+ function on(closure) {
84
+ ExceptionManager.listeners.add(closure);
85
+ }
86
+ ExceptionManager.on = on;
87
+ function off(closure) {
88
+ ExceptionManager.listeners.delete(closure);
89
+ }
90
+ ExceptionManager.off = off;
91
+ /**
92
+ * @internal
93
+ */
94
+ ExceptionManager.tuples = [];
95
+ /**
96
+ * @internal
97
+ */
98
+ ExceptionManager.listeners = new Set();
99
+ })(ExceptionManager = exports.ExceptionManager || (exports.ExceptionManager = {}));
100
+ ExceptionManager.insert(typia_1.TypeGuardError, function (error) {
101
+ return new common_1.HttpException({
102
+ path: error.path,
103
+ reason: error.message,
104
+ message: "Request message is not following the promised type.",
105
+ }, 400);
106
+ });
107
+ ExceptionManager.insert(fetcher_1.HttpError, function (error) {
108
+ return new common_1.HttpException({
109
+ path: error.path,
110
+ message: error.message,
111
+ }, error.status);
112
+ });
113
113
  //# sourceMappingURL=ExceptionManager.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Singleton = void 0;
4
- /**
5
- * @internal
6
- */
7
- var Singleton = /** @class */ (function () {
8
- function Singleton(closure_) {
9
- this.closure_ = closure_;
10
- this.value_ = NOT_MOUNTED_YET;
11
- }
12
- Singleton.prototype.get = function () {
13
- if (this.value_ === NOT_MOUNTED_YET)
14
- this.value_ = this.closure_();
15
- return this.value_;
16
- };
17
- return Singleton;
18
- }());
19
- exports.Singleton = Singleton;
20
- /**
21
- * @internal
22
- */
23
- var NOT_MOUNTED_YET = {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Singleton = void 0;
4
+ /**
5
+ * @internal
6
+ */
7
+ var Singleton = /** @class */ (function () {
8
+ function Singleton(closure_) {
9
+ this.closure_ = closure_;
10
+ this.value_ = NOT_MOUNTED_YET;
11
+ }
12
+ Singleton.prototype.get = function () {
13
+ if (this.value_ === NOT_MOUNTED_YET)
14
+ this.value_ = this.closure_();
15
+ return this.value_;
16
+ };
17
+ return Singleton;
18
+ }());
19
+ exports.Singleton = Singleton;
20
+ /**
21
+ * @internal
22
+ */
23
+ var NOT_MOUNTED_YET = {};
24
24
  //# sourceMappingURL=Singleton.js.map
@@ -0,0 +1,9 @@
1
+ export declare namespace SourceFinder {
2
+ const find: (props: IProps) => Promise<string[]>;
3
+ }
4
+ interface IProps {
5
+ exclude?: string[];
6
+ include: string[];
7
+ filter: (location: string) => boolean;
8
+ }
9
+ export {};