@nestia/core 1.0.18 → 1.1.0-dev.20230413

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 (107) hide show
  1. package/README.md +7 -34
  2. package/lib/decorators/DynamicModule.d.ts +23 -23
  3. package/lib/decorators/DynamicModule.js +103 -103
  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 +49 -49
  9. package/lib/decorators/EncryptedModule.js +161 -161
  10. package/lib/decorators/EncryptedRoute.d.ts +78 -78
  11. package/lib/decorators/EncryptedRoute.js +216 -216
  12. package/lib/decorators/PlainBody.d.ts +22 -22
  13. package/lib/decorators/PlainBody.js +82 -82
  14. package/lib/decorators/TypedBody.d.ts +16 -16
  15. package/lib/decorators/TypedBody.js +94 -94
  16. package/lib/decorators/TypedParam.d.ts +25 -25
  17. package/lib/decorators/TypedParam.js +61 -61
  18. package/lib/decorators/TypedQuery.d.ts +14 -14
  19. package/lib/decorators/TypedQuery.js +99 -99
  20. package/lib/decorators/TypedQuery.js.map +1 -1
  21. package/lib/decorators/TypedRoute.d.ts +72 -72
  22. package/lib/decorators/TypedRoute.js +185 -185
  23. package/lib/decorators/internal/EncryptedConstant.d.ts +1 -1
  24. package/lib/decorators/internal/EncryptedConstant.js +7 -7
  25. package/lib/decorators/internal/TransformError.d.ts +1 -1
  26. package/lib/decorators/internal/TransformError.js +10 -10
  27. package/lib/decorators/internal/get_path_and_stringify.d.ts +1 -1
  28. package/lib/decorators/internal/get_path_and_stringify.js +78 -78
  29. package/lib/decorators/internal/headers_to_object.d.ts +3 -3
  30. package/lib/decorators/internal/headers_to_object.js +49 -49
  31. package/lib/decorators/internal/load_controller.d.ts +2 -2
  32. package/lib/decorators/internal/load_controller.js +151 -152
  33. package/lib/decorators/internal/load_controller.js.map +1 -1
  34. package/lib/decorators/internal/route_error.d.ts +3 -3
  35. package/lib/decorators/internal/route_error.js +86 -86
  36. package/lib/decorators/internal/validate_request_body.d.ts +2 -2
  37. package/lib/decorators/internal/validate_request_body.js +57 -57
  38. package/lib/index.d.ts +3 -3
  39. package/lib/index.js +31 -31
  40. package/lib/module.d.ts +12 -12
  41. package/lib/module.js +28 -28
  42. package/lib/options/INestiaTransformOptions.d.ts +4 -4
  43. package/lib/options/INestiaTransformOptions.js +2 -2
  44. package/lib/options/INestiaTransformProject.d.ts +5 -5
  45. package/lib/options/INestiaTransformProject.js +2 -2
  46. package/lib/options/IRequestBodyValidator.d.ts +16 -16
  47. package/lib/options/IRequestBodyValidator.js +2 -2
  48. package/lib/options/IResponseBodyStringifier.d.ts +20 -20
  49. package/lib/options/IResponseBodyStringifier.js +2 -2
  50. package/lib/programmers/TypedBodyProgrammer.d.ts +5 -5
  51. package/lib/programmers/TypedBodyProgrammer.js +45 -45
  52. package/lib/programmers/TypedQueryProgrammer.d.ts +5 -5
  53. package/lib/programmers/TypedQueryProgrammer.js +260 -165
  54. package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
  55. package/lib/programmers/TypedRouteProgrammer.d.ts +5 -5
  56. package/lib/programmers/TypedRouteProgrammer.js +47 -47
  57. package/lib/transform.d.ts +3 -3
  58. package/lib/transform.js +20 -20
  59. package/lib/transformers/FileTransformer.d.ts +5 -5
  60. package/lib/transformers/FileTransformer.js +32 -32
  61. package/lib/transformers/MethodDecoratorTransformer.d.ts +5 -5
  62. package/lib/transformers/MethodDecoratorTransformer.js +87 -87
  63. package/lib/transformers/MethodTransformer.d.ts +5 -5
  64. package/lib/transformers/MethodTransformer.js +54 -54
  65. package/lib/transformers/MethodTransformer.js.map +1 -1
  66. package/lib/transformers/NodeTransformer.d.ts +5 -5
  67. package/lib/transformers/NodeTransformer.js +20 -20
  68. package/lib/transformers/ParameterDecoratorTransformer.d.ts +5 -5
  69. package/lib/transformers/ParameterDecoratorTransformer.js +53 -53
  70. package/lib/transformers/ParameterTransformer.d.ts +5 -5
  71. package/lib/transformers/ParameterTransformer.js +33 -33
  72. package/lib/transformers/ParameterTransformer.js.map +1 -1
  73. package/lib/typings/Creator.d.ts +3 -3
  74. package/lib/typings/Creator.js +2 -2
  75. package/lib/utils/ExceptionManager.d.ts +64 -64
  76. package/lib/utils/ExceptionManager.js +112 -112
  77. package/lib/utils/Singleton.d.ts +1 -1
  78. package/lib/utils/Singleton.js +23 -23
  79. package/package.json +8 -9
  80. package/src/decorators/TypedQuery.ts +10 -8
  81. package/src/programmers/TypedQueryProgrammer.ts +104 -33
  82. package/src/transformers/MethodTransformer.ts +1 -1
  83. package/src/transformers/ParameterTransformer.ts +1 -1
  84. package/lib/executable/core.d.ts +0 -2
  85. package/lib/executable/core.js +0 -124
  86. package/lib/executable/core.js.map +0 -1
  87. package/lib/executable/internal/ArgumentParser.d.ts +0 -9
  88. package/lib/executable/internal/ArgumentParser.js +0 -256
  89. package/lib/executable/internal/ArgumentParser.js.map +0 -1
  90. package/lib/executable/internal/CommandExecutor.d.ts +0 -3
  91. package/lib/executable/internal/CommandExecutor.js +0 -17
  92. package/lib/executable/internal/CommandExecutor.js.map +0 -1
  93. package/lib/executable/internal/FileRetriever.d.ts +0 -5
  94. package/lib/executable/internal/FileRetriever.js +0 -109
  95. package/lib/executable/internal/FileRetriever.js.map +0 -1
  96. package/lib/executable/internal/PackageManager.d.ts +0 -27
  97. package/lib/executable/internal/PackageManager.js +0 -126
  98. package/lib/executable/internal/PackageManager.js.map +0 -1
  99. package/lib/executable/internal/PluginConfigurator.d.ts +0 -5
  100. package/lib/executable/internal/PluginConfigurator.js +0 -145
  101. package/lib/executable/internal/PluginConfigurator.js.map +0 -1
  102. package/src/executable/core.ts +0 -70
  103. package/src/executable/internal/ArgumentParser.ts +0 -156
  104. package/src/executable/internal/CommandExecutor.ts +0 -8
  105. package/src/executable/internal/FileRetriever.ts +0 -33
  106. package/src/executable/internal/PackageManager.ts +0 -92
  107. package/src/executable/internal/PluginConfigurator.ts +0 -130
@@ -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 +1 @@
1
- {"version":3,"file":"ParameterTransformer.js","sourceRoot":"","sources":["../../src/transformers/ParameterTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAG5B,iFAAgF;AAEhF,IAAiB,oBAAoB,CA+CpC;AA/CD,WAAiB,oBAAoB;IACjC,SAAgB,SAAS,CACrB,OAAgC,EAChC,KAA8B;QAE9B,kBAAkB;QAClB,IAAM,UAAU,GAAwC,oBAAE,CAAC,aAAa;YACpE,CAAC,CAAC,oBAAE,CAAC,aAAa,CAAC,KAAK,CAAC;YACzB,CAAC,CAAE,KAAa,CAAC,UAAU,CAAC;QAChC,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAA;YAAE,OAAO,KAAK,CAAC;QAEtC,gBAAgB;QAChB,IAAM,IAAI,GAAY,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAE/D,yBAAyB;QACzB,IAAI,oBAAE,CAAC,aAAa,KAAK,SAAS;YAC9B,OAAO,oBAAE,CAAC,OAAO,CAAC,0BAA0B,CACxC,KAAK,EACL,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAC,GAAG;gBAC5B,OAAA,oBAAE,CAAC,WAAW,CAAC,GAAG,CAAC;oBACf,CAAC,CAAC,6DAA6B,CAAC,SAAS,CACnC,OAAO,EACP,IAAI,EACJ,GAAG,CACN;oBACH,CAAC,CAAC,GAAG;YANT,CAMS,CACZ,EACD,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,aAAa,EACnB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,WAAW,CACpB,CAAC;QACN,2BAA2B;QAC3B,OAAO,oBAAE,CAAC,OAAO,CAAC,0BAA0B,CACxC,KAAK,EACL,UAAU,CAAC,GAAG,CAAC,UAAC,IAAI;YAChB,OAAA,6DAA6B,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;QAA5D,CAA4D,CAC/D,EACA,KAAa,CAAC,SAAS,EACxB,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,aAAa,EACnB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,WAAW,CACpB,CAAC;IACN,CAAC;IA7Ce,8BAAS,YA6CxB,CAAA;AACL,CAAC,EA/CgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA+CpC"}
1
+ {"version":3,"file":"ParameterTransformer.js","sourceRoot":"","sources":["../../src/transformers/ParameterTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAG5B,iFAAgF;AAEhF,IAAiB,oBAAoB,CA+CpC;AA/CD,WAAiB,oBAAoB;IACjC,SAAgB,SAAS,CACrB,OAAgC,EAChC,KAA8B;QAE9B,kBAAkB;QAClB,IAAM,UAAU,GAAwC,oBAAE,CAAC,aAAa;YACpE,CAAC,CAAC,oBAAE,CAAC,aAAa,CAAC,KAAK,CAAC;YACzB,CAAC,CAAE,KAAa,CAAC,UAAU,CAAC;QAChC,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAA;YAAE,OAAO,KAAK,CAAC;QAEtC,gBAAgB;QAChB,IAAM,IAAI,GAAY,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAE/D,yBAAyB;QACzB,IAAI,oBAAE,CAAC,aAAa,KAAK,SAAS;YAC9B,OAAO,oBAAE,CAAC,OAAO,CAAC,0BAA0B,CACxC,KAAK,EACL,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAC,GAAG;gBAC5B,OAAA,oBAAE,CAAC,WAAW,CAAC,GAAG,CAAC;oBACf,CAAC,CAAC,6DAA6B,CAAC,SAAS,CACnC,OAAO,EACP,IAAI,EACJ,GAAG,CACN;oBACH,CAAC,CAAC,GAAG;YANT,CAMS,CACZ,EACD,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,aAAa,EACnB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,WAAW,CACpB,CAAC;QACN,2BAA2B;QAC3B,OAAQ,oBAAE,CAAC,OAAO,CAAC,0BAAkC,CACjD,KAAK,EACL,UAAU,CAAC,GAAG,CAAC,UAAC,IAAI;YAChB,OAAA,6DAA6B,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;QAA5D,CAA4D,CAC/D,EACA,KAAa,CAAC,SAAS,EACxB,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,aAAa,EACnB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,WAAW,CACpB,CAAC;IACN,CAAC;IA7Ce,8BAAS,YA6CxB,CAAA;AACL,CAAC,EA/CgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA+CpC"}
@@ -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
package/package.json CHANGED
@@ -1,19 +1,17 @@
1
1
  {
2
2
  "name": "@nestia/core",
3
- "version": "1.0.18",
3
+ "version": "1.1.0-dev.20230413",
4
4
  "description": "Super-fast validation decorators of NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
- "bin": {
8
- "@nestia/core": "lib/executable/core.js"
9
- },
10
7
  "scripts": {
11
8
  "build": "rimraf lib && tsc",
12
- "build:test": "rimraf bin && ttsc -p test/tsconfig.json",
9
+ "build:test": "rimraf bin && tsc -p test/tsconfig.json",
13
10
  "dev": "npm run build -- --watch",
14
11
  "eslint": "eslint ./**/*.ts",
15
12
  "eslint:fix": "eslint ./**/*.ts --fix",
16
13
  "package": "npm publish --access public",
14
+ "prepare": "ts-patch install",
17
15
  "prettier": "prettier ./**/*.ts --write",
18
16
  "test": "node bin/test"
19
17
  },
@@ -47,11 +45,12 @@
47
45
  "eslint-plugin-deprecation": "^1.3.3",
48
46
  "git-last-commit": "^1.0.1",
49
47
  "inquirer": "^8.2.5",
48
+ "prettier": "^2.8.7",
50
49
  "rimraf": "^3.0.2",
51
50
  "ts-node": "^10.9.1",
51
+ "ts-patch": "^3.0.0-beta2",
52
52
  "tstl": "^2.5.13",
53
- "ttypescript": "^1.5.15",
54
- "typescript": "^4.9.5",
53
+ "typescript": "^5.0.4",
55
54
  "typescript-transform-paths": "^3.4.6"
56
55
  },
57
56
  "dependencies": {
@@ -63,10 +62,10 @@
63
62
  "raw-body": "*",
64
63
  "reflect-metadata": "*",
65
64
  "rxjs": "*",
66
- "typia": "^3.6.8"
65
+ "typia": "^3.7.4"
67
66
  },
68
67
  "peerDependencies": {
69
- "typescript": ">= 4.5.2 && < 5.0.0"
68
+ "typescript": ">= 4.5.2"
70
69
  },
71
70
  "files": [
72
71
  "README.md",
@@ -37,17 +37,19 @@ export function TypedQuery<T>(
37
37
  * @internal
38
38
  */
39
39
  export namespace TypedQuery {
40
- export function boolean(str: string | null): boolean | undefined {
41
- return str !== null ? Boolean(str) : undefined;
40
+ export function boolean(
41
+ str: string | null | undefined,
42
+ ): boolean | undefined {
43
+ return str?.length ? Boolean(str) : undefined;
42
44
  }
43
- export function number(str: string | null): number | undefined {
44
- return str !== null ? Number(str) : undefined;
45
+ export function number(str: string | null | undefined): number | undefined {
46
+ return str?.length ? Number(str) : undefined;
45
47
  }
46
- export function bigint(str: string | null): bigint | undefined {
47
- return str !== null ? BigInt(str) : undefined;
48
+ export function bigint(str: string | null | undefined): bigint | undefined {
49
+ return str?.length ? BigInt(str) : undefined;
48
50
  }
49
- export function string(str: string | null): string | undefined {
50
- return str ?? undefined;
51
+ export function string(str: string | null | undefined): string | undefined {
52
+ return str !== undefined && str !== null ? str : undefined;
51
53
  }
52
54
  }
53
55
  Object.assign(TypedQuery, assert);