@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,186 +1,186 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
- var __values = (this && this.__values) || function(o) {
28
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
- if (m) return m.call(o);
30
- if (o && typeof o.length === "number") return {
31
- next: function () {
32
- if (o && i >= o.length) o = void 0;
33
- return { value: o && o[i++], done: !o };
34
- }
35
- };
36
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
- };
38
- var e_1, _a, e_2, _b, e_3, _c;
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.TypedRoute = void 0;
41
- var common_1 = require("@nestjs/common");
42
- var rxjs_1 = require("rxjs");
43
- var typia_1 = require("typia");
44
- var get_path_and_stringify_1 = require("./internal/get_path_and_stringify");
45
- var route_error_1 = require("./internal/route_error");
46
- /**
47
- * Type safe router decorator functions.
48
- *
49
- * `TypedRoute` is a module containing router decorator functions which can boost up
50
- * JSON string conversion speed about 50x times faster than `class-transformer`.
51
- * Furthermore, such JSON string conversion is even type safe through
52
- * [typia](https://github.com/samchon/typia).
53
- *
54
- * For reference, router functions of `TypedRoute` can convert custom error classes to
55
- * the regular {@link nest.HttpException} class automatically, through
56
- * {@link ExceptionManager}.
57
- *
58
- * @author Jeongho Nam - https://github.com/samchon
59
- */
60
- var TypedRoute;
61
- (function (TypedRoute) {
62
- /**
63
- * Router decorator function for the GET method.
64
- *
65
- * @param path Path of the HTTP request
66
- * @returns Method decorator
67
- */
68
- TypedRoute.Get = Generator("Get");
69
- /**
70
- * Router decorator function for the POST method.
71
- *
72
- * @param path Path of the HTTP request
73
- * @returns Method decorator
74
- */
75
- TypedRoute.Post = Generator("Post");
76
- /**
77
- * Router decorator function for the PATH method.
78
- *
79
- * @param path Path of the HTTP request
80
- * @returns Method decorator
81
- */
82
- TypedRoute.Patch = Generator("Patch");
83
- /**
84
- * Router decorator function for the PUT method.
85
- *
86
- * @param path Path of the HTTP request
87
- * @returns Method decorator
88
- */
89
- TypedRoute.Put = Generator("Put");
90
- /**
91
- * Router decorator function for the DELETE method.
92
- *
93
- * @param path Path of the HTTP request
94
- * @returns Method decorator
95
- */
96
- TypedRoute.Delete = Generator("Delete");
97
- /**
98
- * @internal
99
- */
100
- function Generator(method) {
101
- function route() {
102
- var args = [];
103
- for (var _i = 0; _i < arguments.length; _i++) {
104
- args[_i] = arguments[_i];
105
- }
106
- var _a = __read((0, get_path_and_stringify_1.get_path_and_stringify)("TypedRoute.".concat(method)).apply(void 0, __spreadArray([], __read(args), false)), 2), path = _a[0], stringify = _a[1];
107
- return (0, common_1.applyDecorators)(ROUTERS[method](path), (0, common_1.UseInterceptors)(new TypedRouteInterceptor(stringify)));
108
- }
109
- return route;
110
- }
111
- })(TypedRoute = exports.TypedRoute || (exports.TypedRoute = {}));
112
- try {
113
- for (var _d = __values([
114
- typia_1.isStringify,
115
- typia_1.assertStringify,
116
- typia_1.validateStringify,
117
- typia_1.stringify,
118
- ]), _e = _d.next(); !_e.done; _e = _d.next()) {
119
- var method = _e.value;
120
- try {
121
- for (var _f = (e_2 = void 0, __values(Object.entries(method))), _g = _f.next(); !_g.done; _g = _f.next()) {
122
- var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
123
- try {
124
- for (var _j = (e_3 = void 0, __values([
125
- TypedRoute.Get,
126
- TypedRoute.Delete,
127
- TypedRoute.Post,
128
- TypedRoute.Put,
129
- TypedRoute.Patch,
130
- ])), _k = _j.next(); !_k.done; _k = _j.next()) {
131
- var deco = _k.value;
132
- deco[key] = value;
133
- }
134
- }
135
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
136
- finally {
137
- try {
138
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
139
- }
140
- finally { if (e_3) throw e_3.error; }
141
- }
142
- }
143
- }
144
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
145
- finally {
146
- try {
147
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
148
- }
149
- finally { if (e_2) throw e_2.error; }
150
- }
151
- }
152
- }
153
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
154
- finally {
155
- try {
156
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
157
- }
158
- finally { if (e_1) throw e_1.error; }
159
- }
160
- /**
161
- * @internal
162
- */
163
- var TypedRouteInterceptor = /** @class */ (function () {
164
- function TypedRouteInterceptor(stringify) {
165
- this.stringify = stringify;
166
- }
167
- TypedRouteInterceptor.prototype.intercept = function (context, next) {
168
- var _this = this;
169
- var http = context.switchToHttp();
170
- var response = http.getResponse();
171
- response.header("Content-Type", "application/json");
172
- return next.handle().pipe((0, rxjs_1.map)(function (value) { return _this.stringify(value); }), (0, rxjs_1.catchError)(function (err) { return (0, route_error_1.route_error)(http.getRequest(), err); }));
173
- };
174
- return TypedRouteInterceptor;
175
- }());
176
- /**
177
- * @internal
178
- */
179
- var ROUTERS = {
180
- Get: common_1.Get,
181
- Post: common_1.Post,
182
- Patch: common_1.Patch,
183
- Put: common_1.Put,
184
- Delete: common_1.Delete,
185
- };
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ var __values = (this && this.__values) || function(o) {
28
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
+ if (m) return m.call(o);
30
+ if (o && typeof o.length === "number") return {
31
+ next: function () {
32
+ if (o && i >= o.length) o = void 0;
33
+ return { value: o && o[i++], done: !o };
34
+ }
35
+ };
36
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
+ };
38
+ var e_1, _a, e_2, _b, e_3, _c;
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.TypedRoute = void 0;
41
+ var common_1 = require("@nestjs/common");
42
+ var rxjs_1 = require("rxjs");
43
+ var typia_1 = require("typia");
44
+ var get_path_and_stringify_1 = require("./internal/get_path_and_stringify");
45
+ var route_error_1 = require("./internal/route_error");
46
+ /**
47
+ * Type safe router decorator functions.
48
+ *
49
+ * `TypedRoute` is a module containing router decorator functions which can boost up
50
+ * JSON string conversion speed about 50x times faster than `class-transformer`.
51
+ * Furthermore, such JSON string conversion is even type safe through
52
+ * [typia](https://github.com/samchon/typia).
53
+ *
54
+ * For reference, router functions of `TypedRoute` can convert custom error classes to
55
+ * the regular {@link nest.HttpException} class automatically, through
56
+ * {@link ExceptionManager}.
57
+ *
58
+ * @author Jeongho Nam - https://github.com/samchon
59
+ */
60
+ var TypedRoute;
61
+ (function (TypedRoute) {
62
+ /**
63
+ * Router decorator function for the GET method.
64
+ *
65
+ * @param path Path of the HTTP request
66
+ * @returns Method decorator
67
+ */
68
+ TypedRoute.Get = Generator("Get");
69
+ /**
70
+ * Router decorator function for the POST method.
71
+ *
72
+ * @param path Path of the HTTP request
73
+ * @returns Method decorator
74
+ */
75
+ TypedRoute.Post = Generator("Post");
76
+ /**
77
+ * Router decorator function for the PATH method.
78
+ *
79
+ * @param path Path of the HTTP request
80
+ * @returns Method decorator
81
+ */
82
+ TypedRoute.Patch = Generator("Patch");
83
+ /**
84
+ * Router decorator function for the PUT method.
85
+ *
86
+ * @param path Path of the HTTP request
87
+ * @returns Method decorator
88
+ */
89
+ TypedRoute.Put = Generator("Put");
90
+ /**
91
+ * Router decorator function for the DELETE method.
92
+ *
93
+ * @param path Path of the HTTP request
94
+ * @returns Method decorator
95
+ */
96
+ TypedRoute.Delete = Generator("Delete");
97
+ /**
98
+ * @internal
99
+ */
100
+ function Generator(method) {
101
+ function route() {
102
+ var args = [];
103
+ for (var _i = 0; _i < arguments.length; _i++) {
104
+ args[_i] = arguments[_i];
105
+ }
106
+ var _a = __read((0, get_path_and_stringify_1.get_path_and_stringify)("TypedRoute.".concat(method)).apply(void 0, __spreadArray([], __read(args), false)), 2), path = _a[0], stringify = _a[1];
107
+ return (0, common_1.applyDecorators)(ROUTERS[method](path), (0, common_1.UseInterceptors)(new TypedRouteInterceptor(stringify)));
108
+ }
109
+ return route;
110
+ }
111
+ })(TypedRoute = exports.TypedRoute || (exports.TypedRoute = {}));
112
+ try {
113
+ for (var _d = __values([
114
+ typia_1.isStringify,
115
+ typia_1.assertStringify,
116
+ typia_1.validateStringify,
117
+ typia_1.stringify,
118
+ ]), _e = _d.next(); !_e.done; _e = _d.next()) {
119
+ var method = _e.value;
120
+ try {
121
+ for (var _f = (e_2 = void 0, __values(Object.entries(method))), _g = _f.next(); !_g.done; _g = _f.next()) {
122
+ var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
123
+ try {
124
+ for (var _j = (e_3 = void 0, __values([
125
+ TypedRoute.Get,
126
+ TypedRoute.Delete,
127
+ TypedRoute.Post,
128
+ TypedRoute.Put,
129
+ TypedRoute.Patch,
130
+ ])), _k = _j.next(); !_k.done; _k = _j.next()) {
131
+ var deco = _k.value;
132
+ deco[key] = value;
133
+ }
134
+ }
135
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
136
+ finally {
137
+ try {
138
+ if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
139
+ }
140
+ finally { if (e_3) throw e_3.error; }
141
+ }
142
+ }
143
+ }
144
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
145
+ finally {
146
+ try {
147
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
148
+ }
149
+ finally { if (e_2) throw e_2.error; }
150
+ }
151
+ }
152
+ }
153
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
154
+ finally {
155
+ try {
156
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
157
+ }
158
+ finally { if (e_1) throw e_1.error; }
159
+ }
160
+ /**
161
+ * @internal
162
+ */
163
+ var TypedRouteInterceptor = /** @class */ (function () {
164
+ function TypedRouteInterceptor(stringify) {
165
+ this.stringify = stringify;
166
+ }
167
+ TypedRouteInterceptor.prototype.intercept = function (context, next) {
168
+ var _this = this;
169
+ var http = context.switchToHttp();
170
+ var response = http.getResponse();
171
+ response.header("Content-Type", "application/json");
172
+ return next.handle().pipe((0, rxjs_1.map)(function (value) { return _this.stringify(value); }), (0, rxjs_1.catchError)(function (err) { return (0, route_error_1.route_error)(http.getRequest(), err); }));
173
+ };
174
+ return TypedRouteInterceptor;
175
+ }());
176
+ /**
177
+ * @internal
178
+ */
179
+ var ROUTERS = {
180
+ Get: common_1.Get,
181
+ Post: common_1.Post,
182
+ Patch: common_1.Patch,
183
+ Put: common_1.Put,
184
+ Delete: common_1.Delete,
185
+ };
186
186
  //# sourceMappingURL=TypedRoute.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENCRYPTION_METADATA_KEY = void 0;
4
- /**
5
- * @internal
6
- */
7
- exports.ENCRYPTION_METADATA_KEY = "nestia:core:encryption:password";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ENCRYPTION_METADATA_KEY = void 0;
4
+ /**
5
+ * @internal
6
+ */
7
+ exports.ENCRYPTION_METADATA_KEY = "nestia:core:encryption:password";
8
8
  //# sourceMappingURL=EncryptedConstant.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransformError = void 0;
4
- /**
5
- * @internal
6
- */
7
- function TransformError(method) {
8
- return new Error("Error on nestia.core.".concat(method, "(): no transform has been configured. Configure \"tsconfig.json\" file following [Guide Documents](https://github.com/samchon/nestia/wiki/Setup#tsconfigjson)."));
9
- }
10
- exports.TransformError = TransformError;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransformError = void 0;
4
+ /**
5
+ * @internal
6
+ */
7
+ function TransformError(method) {
8
+ return new Error("Error on nestia.core.".concat(method, "(): no transform has been configured. Configure \"tsconfig.json\" file following [Guide Documents](https://github.com/samchon/nestia/wiki/Setup#tsconfigjson)."));
9
+ }
10
+ exports.TransformError = TransformError;
11
11
  //# sourceMappingURL=TransformError.js.map
@@ -1 +1 @@
1
- export declare const get_path_and_stringify: (method: string) => (...args: any[]) => [string | string[] | undefined, (input: any) => string];
1
+ export declare const get_path_and_stringify: (method: string) => (...args: any[]) => [string | string[] | undefined, (input: any) => string];
@@ -1,79 +1,79 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.get_path_and_stringify = void 0;
4
- var common_1 = require("@nestjs/common");
5
- var typia_1 = require("typia");
6
- var TransformError_1 = require("./TransformError");
7
- var get_path_and_stringify = function (method) {
8
- return function () {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var path = args[0] === undefined ||
14
- typeof args[0] === "string" ||
15
- Array.isArray(args[0])
16
- ? args[0]
17
- : null;
18
- var functor = path === null ? args[0] : args[1];
19
- return [path !== null && path !== void 0 ? path : undefined, take(method)(functor)];
20
- };
21
- };
22
- exports.get_path_and_stringify = get_path_and_stringify;
23
- var take = function (method) {
24
- return function (functor) {
25
- if (functor === undefined)
26
- throw (0, TransformError_1.TransformError)(method);
27
- else if (functor === null)
28
- return JSON.stringify;
29
- else if (functor.type === "stringify")
30
- return functor.stringify;
31
- else if (functor.type === "assert")
32
- return assert(functor.assert);
33
- else if (functor.type === "is")
34
- return is(functor.is);
35
- else if (functor.type === "validate")
36
- return validate(functor.validate);
37
- throw new Error("Error on nestia.core.".concat(method, "(): invalid typed stringify function."));
38
- };
39
- };
40
- var assert = function (closure) {
41
- return function (data) {
42
- try {
43
- return closure(data);
44
- }
45
- catch (exp) {
46
- if (exp instanceof typia_1.TypeGuardError) {
47
- throw new common_1.InternalServerErrorException({
48
- path: exp.path,
49
- reason: exp.message,
50
- expected: exp.expected,
51
- value: exp.value,
52
- message: MESSAGE,
53
- });
54
- }
55
- throw exp;
56
- }
57
- };
58
- };
59
- var is = function (closure) {
60
- return function (data) {
61
- var result = closure(data);
62
- if (result === null)
63
- throw new common_1.InternalServerErrorException(MESSAGE);
64
- return result;
65
- };
66
- };
67
- var validate = function (closure) {
68
- return function (data) {
69
- var result = closure(data);
70
- if (result.success === false)
71
- throw new common_1.InternalServerErrorException({
72
- errors: result.errors,
73
- message: MESSAGE,
74
- });
75
- return result.data;
76
- };
77
- };
78
- var MESSAGE = "Response body data is not following the promised type.";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.get_path_and_stringify = void 0;
4
+ var common_1 = require("@nestjs/common");
5
+ var typia_1 = require("typia");
6
+ var TransformError_1 = require("./TransformError");
7
+ var get_path_and_stringify = function (method) {
8
+ return function () {
9
+ var args = [];
10
+ for (var _i = 0; _i < arguments.length; _i++) {
11
+ args[_i] = arguments[_i];
12
+ }
13
+ var path = args[0] === undefined ||
14
+ typeof args[0] === "string" ||
15
+ Array.isArray(args[0])
16
+ ? args[0]
17
+ : null;
18
+ var functor = path === null ? args[0] : args[1];
19
+ return [path !== null && path !== void 0 ? path : undefined, take(method)(functor)];
20
+ };
21
+ };
22
+ exports.get_path_and_stringify = get_path_and_stringify;
23
+ var take = function (method) {
24
+ return function (functor) {
25
+ if (functor === undefined)
26
+ throw (0, TransformError_1.TransformError)(method);
27
+ else if (functor === null)
28
+ return JSON.stringify;
29
+ else if (functor.type === "stringify")
30
+ return functor.stringify;
31
+ else if (functor.type === "assert")
32
+ return assert(functor.assert);
33
+ else if (functor.type === "is")
34
+ return is(functor.is);
35
+ else if (functor.type === "validate")
36
+ return validate(functor.validate);
37
+ throw new Error("Error on nestia.core.".concat(method, "(): invalid typed stringify function."));
38
+ };
39
+ };
40
+ var assert = function (closure) {
41
+ return function (data) {
42
+ try {
43
+ return closure(data);
44
+ }
45
+ catch (exp) {
46
+ if (exp instanceof typia_1.TypeGuardError) {
47
+ throw new common_1.InternalServerErrorException({
48
+ path: exp.path,
49
+ reason: exp.message,
50
+ expected: exp.expected,
51
+ value: exp.value,
52
+ message: MESSAGE,
53
+ });
54
+ }
55
+ throw exp;
56
+ }
57
+ };
58
+ };
59
+ var is = function (closure) {
60
+ return function (data) {
61
+ var result = closure(data);
62
+ if (result === null)
63
+ throw new common_1.InternalServerErrorException(MESSAGE);
64
+ return result;
65
+ };
66
+ };
67
+ var validate = function (closure) {
68
+ return function (data) {
69
+ var result = closure(data);
70
+ if (result.success === false)
71
+ throw new common_1.InternalServerErrorException({
72
+ errors: result.errors,
73
+ message: MESSAGE,
74
+ });
75
+ return result.data;
76
+ };
77
+ };
78
+ var MESSAGE = "Response body data is not following the promised type.";
79
79
  //# sourceMappingURL=get_path_and_stringify.js.map
@@ -1,3 +1,3 @@
1
- /// <reference types="node" />
2
- import http from "http";
3
- export declare function headers_to_object(headers: http.IncomingHttpHeaders): Record<string, string>;
1
+ /// <reference types="node" />
2
+ import http from "http";
3
+ export declare function headers_to_object(headers: http.IncomingHttpHeaders): Record<string, string>;