@nestia/core 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -285
- package/lib/decorators/DynamicModule.d.ts +20 -1
- package/lib/decorators/DynamicModule.js +22 -3
- package/lib/decorators/DynamicModule.js.map +1 -1
- package/lib/decorators/EncryptedBody.d.ts +8 -7
- package/lib/decorators/EncryptedBody.js +8 -7
- package/lib/decorators/EncryptedBody.js.map +1 -1
- package/lib/decorators/EncryptedRoute.d.ts +7 -8
- package/lib/decorators/EncryptedRoute.js +9 -9
- package/lib/decorators/EncryptedRoute.js.map +1 -1
- package/lib/decorators/TypedBody.d.ts +8 -6
- package/lib/decorators/TypedBody.js +8 -6
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedParam.d.ts +5 -5
- package/lib/decorators/TypedParam.js +5 -5
- package/lib/decorators/TypedQuery.d.ts +14 -1
- package/lib/decorators/TypedQuery.js +18 -1
- package/lib/decorators/TypedQuery.js.map +1 -1
- package/lib/decorators/TypedRoute.d.ts +6 -5
- package/lib/decorators/TypedRoute.js +6 -5
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/decorators/internal/TransformError.d.ts +1 -0
- package/lib/decorators/internal/TransformError.js +11 -0
- package/lib/decorators/internal/TransformError.js.map +1 -0
- package/lib/decorators/internal/get_path_and_stringify.js +2 -1
- package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
- package/lib/decorators/internal/validate_request_body.js +2 -1
- package/lib/decorators/internal/validate_request_body.js.map +1 -1
- package/lib/executable/core.js +45 -23
- package/lib/executable/core.js.map +1 -1
- package/lib/executable/internal/ArgumentParser.d.ts +9 -0
- package/lib/executable/internal/ArgumentParser.js +269 -0
- package/lib/executable/internal/ArgumentParser.js.map +1 -0
- package/lib/executable/internal/CommandExecutor.d.ts +3 -0
- package/lib/executable/internal/CommandExecutor.js +17 -0
- package/lib/executable/internal/CommandExecutor.js.map +1 -0
- package/lib/executable/internal/PackageManager.d.ts +27 -0
- package/lib/executable/internal/PackageManager.js +140 -0
- package/lib/executable/internal/PackageManager.js.map +1 -0
- package/lib/executable/internal/PluginConfigurator.d.ts +5 -0
- package/lib/executable/internal/PluginConfigurator.js +168 -0
- package/lib/executable/internal/PluginConfigurator.js.map +1 -0
- package/package.json +8 -3
- package/src/decorators/DynamicModule.ts +21 -2
- package/src/decorators/EncryptedBody.ts +12 -8
- package/src/decorators/EncryptedRoute.ts +10 -11
- package/src/decorators/TypedBody.ts +9 -6
- package/src/decorators/TypedParam.ts +6 -6
- package/src/decorators/TypedQuery.ts +22 -3
- package/src/decorators/TypedRoute.ts +7 -5
- package/src/decorators/internal/TransformError.ts +8 -0
- package/src/decorators/internal/get_path_and_stringify.ts +3 -4
- package/src/decorators/internal/validate_request_body.ts +3 -4
- package/src/executable/core.ts +39 -18
- package/src/executable/internal/ArgumentParser.ts +144 -0
- package/src/executable/internal/CommandExecutor.ts +8 -0
- package/src/executable/internal/PackageManager.ts +99 -0
- package/src/executable/internal/PluginConfigurator.ts +128 -0
- package/lib/executable/internal/CommandParser.d.ts +0 -3
- package/lib/executable/internal/CommandParser.js +0 -21
- package/lib/executable/internal/CommandParser.js.map +0 -1
- package/lib/executable/internal/CoreSetupWizard.d.ts +0 -8
- package/lib/executable/internal/CoreSetupWizard.js +0 -271
- package/lib/executable/internal/CoreSetupWizard.js.map +0 -1
- package/src/executable/internal/CommandParser.ts +0 -15
- package/src/executable/internal/CoreSetupWizard.ts +0 -225
|
@@ -0,0 +1,17 @@
|
|
|
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.CommandExecutor = void 0;
|
|
7
|
+
var child_process_1 = __importDefault(require("child_process"));
|
|
8
|
+
var CommandExecutor;
|
|
9
|
+
(function (CommandExecutor) {
|
|
10
|
+
function run(str, silent) {
|
|
11
|
+
if (silent === false)
|
|
12
|
+
console.log(str);
|
|
13
|
+
child_process_1.default.execSync(str, { stdio: "ignore" });
|
|
14
|
+
}
|
|
15
|
+
CommandExecutor.run = run;
|
|
16
|
+
})(CommandExecutor = exports.CommandExecutor || (exports.CommandExecutor = {}));
|
|
17
|
+
//# sourceMappingURL=CommandExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../../src/executable/internal/CommandExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,gEAA+B;AAE/B,IAAiB,eAAe,CAK/B;AALD,WAAiB,eAAe;IAC5B,SAAgB,GAAG,CAAC,GAAW,EAAE,MAAe;QAC5C,IAAI,MAAM,KAAK,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,uBAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;IAHe,mBAAG,MAGlB,CAAA;AACL,CAAC,EALgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK/B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class PackageManager {
|
|
2
|
+
readonly directory: string;
|
|
3
|
+
data: Package.Data;
|
|
4
|
+
manager: string;
|
|
5
|
+
get file(): string;
|
|
6
|
+
static mount(): Promise<PackageManager>;
|
|
7
|
+
save(modifier: (data: Package.Data) => void): Promise<void>;
|
|
8
|
+
install(props: {
|
|
9
|
+
dev: boolean;
|
|
10
|
+
silent?: boolean;
|
|
11
|
+
modulo: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
}): boolean;
|
|
14
|
+
erase(props: {
|
|
15
|
+
modulo: string;
|
|
16
|
+
silent?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
private constructor();
|
|
19
|
+
private static load;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace Package {
|
|
22
|
+
interface Data {
|
|
23
|
+
scripts?: Record<string, string>;
|
|
24
|
+
dependencies?: Record<string, string>;
|
|
25
|
+
devDependencies?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.PackageManager = void 0;
|
|
43
|
+
var fs_1 = __importDefault(require("fs"));
|
|
44
|
+
var path_1 = __importDefault(require("path"));
|
|
45
|
+
var CommandExecutor_1 = require("./CommandExecutor");
|
|
46
|
+
var PackageManager = /** @class */ (function () {
|
|
47
|
+
function PackageManager(directory, data) {
|
|
48
|
+
this.directory = directory;
|
|
49
|
+
this.data = data;
|
|
50
|
+
this.manager = "npm";
|
|
51
|
+
}
|
|
52
|
+
Object.defineProperty(PackageManager.prototype, "file", {
|
|
53
|
+
get: function () {
|
|
54
|
+
return path_1.default.join(this.directory, "package.json");
|
|
55
|
+
},
|
|
56
|
+
enumerable: false,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
59
|
+
PackageManager.mount = function () {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var location, _a, _b;
|
|
62
|
+
return __generator(this, function (_c) {
|
|
63
|
+
switch (_c.label) {
|
|
64
|
+
case 0: return [4 /*yield*/, find(process.cwd())];
|
|
65
|
+
case 1:
|
|
66
|
+
location = _c.sent();
|
|
67
|
+
if (location === null)
|
|
68
|
+
throw new Error("Unable to find \"package.json\" file");
|
|
69
|
+
_a = PackageManager.bind;
|
|
70
|
+
_b = [void 0, location];
|
|
71
|
+
return [4 /*yield*/, this.load(path_1.default.join(location, "package.json"))];
|
|
72
|
+
case 2: return [2 /*return*/, new (_a.apply(PackageManager, _b.concat([_c.sent()])))()];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
PackageManager.prototype.save = function (modifier) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var content;
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0: return [4 /*yield*/, fs_1.default.promises.readFile(this.file, "utf8")];
|
|
83
|
+
case 1:
|
|
84
|
+
content = _a.sent();
|
|
85
|
+
this.data = JSON.parse(content);
|
|
86
|
+
modifier(this.data);
|
|
87
|
+
return [2 /*return*/, fs_1.default.promises.writeFile(this.file, JSON.stringify(this.data, null, 2), "utf8")];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
PackageManager.prototype.install = function (props) {
|
|
93
|
+
var container = props.dev
|
|
94
|
+
? this.data.devDependencies
|
|
95
|
+
: this.data.dependencies;
|
|
96
|
+
if (!!(container === null || container === void 0 ? void 0 : container[props.modulo]) &&
|
|
97
|
+
fs_1.default.existsSync(path_1.default.join(this.directory, "node_modules", props.modulo)))
|
|
98
|
+
return false;
|
|
99
|
+
var middle = this.manager === "yarn"
|
|
100
|
+
? "add".concat(props.dev ? " -D" : "")
|
|
101
|
+
: "install ".concat(props.dev ? "--save-dev" : "--save");
|
|
102
|
+
CommandExecutor_1.CommandExecutor.run("".concat(this.manager, " ").concat(middle, " ").concat(props.modulo).concat(props.version ? "@".concat(props.version) : ""), !!props.silent);
|
|
103
|
+
return true;
|
|
104
|
+
};
|
|
105
|
+
PackageManager.prototype.erase = function (props) {
|
|
106
|
+
var middle = this.manager === "yarn" ? "remove" : "uninstall";
|
|
107
|
+
CommandExecutor_1.CommandExecutor.run("".concat(this.manager, " ").concat(middle, " ").concat(props.modulo), !!props.silent);
|
|
108
|
+
};
|
|
109
|
+
PackageManager.load = function (file) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var content;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, fs_1.default.promises.readFile(file, "utf8")];
|
|
115
|
+
case 1:
|
|
116
|
+
content = _a.sent();
|
|
117
|
+
return [2 /*return*/, JSON.parse(content)];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return PackageManager;
|
|
123
|
+
}());
|
|
124
|
+
exports.PackageManager = PackageManager;
|
|
125
|
+
function find(directory, depth) {
|
|
126
|
+
if (directory === void 0) { directory = process.cwd(); }
|
|
127
|
+
if (depth === void 0) { depth = 0; }
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var location;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
location = path_1.default.join(directory, "package.json");
|
|
132
|
+
if (fs_1.default.existsSync(location))
|
|
133
|
+
return [2 /*return*/, directory];
|
|
134
|
+
else if (depth > 1)
|
|
135
|
+
return [2 /*return*/, null];
|
|
136
|
+
return [2 /*return*/, find(path_1.default.join(directory, ".."), depth + 1)];
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=PackageManager.js.map
|
|
@@ -0,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,CAAC,OAAO,cAAI,MAAM,cAAI,KAAK,CAAC,MAAM,CAAE,EAC3C,CAAC,CAAC,KAAK,CAAC,MAAM,CACjB,CAAC;IACN,CAAC;IAOoB,mBAAI,GAAzB,UAA0B,IAAY;;;;;4BACV,qBAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAA;;wBAA1D,OAAO,GAAW,SAAwC;wBAChE,sBAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAC;;;;KAC9B;IACL,qBAAC;AAAD,CAAC,AA5ED,IA4EC;AA5EY,wCAAc;AAqF3B,SAAe,IAAI,CACf,SAAiC,EACjC,KAAiB;IADjB,0BAAA,EAAA,YAAoB,OAAO,CAAC,GAAG,EAAE;IACjC,sBAAA,EAAA,SAAiB;;;;YAEX,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;YAC9D,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,sBAAO,SAAS,EAAC;iBACzC,IAAI,KAAK,GAAG,CAAC;gBAAE,sBAAO,IAAI,EAAC;YAChC,sBAAO,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAC;;;CACtD"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.PluginConfigurator = void 0;
|
|
66
|
+
var fs_1 = __importDefault(require("fs"));
|
|
67
|
+
var path_1 = __importDefault(require("path"));
|
|
68
|
+
var PluginConfigurator;
|
|
69
|
+
(function (PluginConfigurator) {
|
|
70
|
+
function configure(pack, args) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var installed, error;
|
|
73
|
+
var _this = this;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
installed = pack.install({
|
|
78
|
+
dev: true,
|
|
79
|
+
modulo: "comment-json",
|
|
80
|
+
version: "4.2.3",
|
|
81
|
+
silent: true,
|
|
82
|
+
});
|
|
83
|
+
return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
var exp_1;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
_a.trys.push([0, 2, , 3]);
|
|
89
|
+
return [4 /*yield*/, _Configure(pack, args)];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [2 /*return*/, null];
|
|
93
|
+
case 2:
|
|
94
|
+
exp_1 = _a.sent();
|
|
95
|
+
return [2 /*return*/, exp_1];
|
|
96
|
+
case 3: return [2 /*return*/];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}); })()];
|
|
100
|
+
case 1:
|
|
101
|
+
error = _a.sent();
|
|
102
|
+
// REMOVE IT
|
|
103
|
+
if (installed)
|
|
104
|
+
pack.erase({
|
|
105
|
+
modulo: "comment-json",
|
|
106
|
+
silent: true,
|
|
107
|
+
});
|
|
108
|
+
if (error !== null)
|
|
109
|
+
throw error;
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
PluginConfigurator.configure = configure;
|
|
116
|
+
function _Configure(pack, args) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var Comment, config, _a, _b, compilerOptions, plugins, strict, core, typia;
|
|
119
|
+
return __generator(this, function (_c) {
|
|
120
|
+
var _d;
|
|
121
|
+
switch (_c.label) {
|
|
122
|
+
case 0: return [4 /*yield*/, (_d = path_1.default.join(pack.directory, "node_modules", "comment-json"), Promise.resolve().then(function () { return __importStar(require(_d)); }))];
|
|
123
|
+
case 1:
|
|
124
|
+
Comment = _c.sent();
|
|
125
|
+
_b = (_a = Comment).parse;
|
|
126
|
+
return [4 /*yield*/, fs_1.default.promises.readFile(args.project, "utf8")];
|
|
127
|
+
case 2:
|
|
128
|
+
config = _b.apply(_a, [_c.sent()]);
|
|
129
|
+
compilerOptions = config.compilerOptions;
|
|
130
|
+
if (compilerOptions === undefined)
|
|
131
|
+
throw new Error("".concat(args.project, " file does not have \"compilerOptions\" property."));
|
|
132
|
+
plugins = (function () {
|
|
133
|
+
var plugins = compilerOptions.plugins;
|
|
134
|
+
if (plugins === undefined)
|
|
135
|
+
return (compilerOptions.plugins = []);
|
|
136
|
+
else if (!Array.isArray(plugins))
|
|
137
|
+
throw new Error("\"plugins\" property of ".concat(args.project, " must be array type."));
|
|
138
|
+
return plugins;
|
|
139
|
+
})();
|
|
140
|
+
strict = compilerOptions.strict === true;
|
|
141
|
+
core = plugins.find(function (p) {
|
|
142
|
+
return typeof p === "object" &&
|
|
143
|
+
p !== null &&
|
|
144
|
+
p.transform === "@nestia/core/lib/transform";
|
|
145
|
+
});
|
|
146
|
+
typia = plugins.find(function (p) {
|
|
147
|
+
return typeof p === "object" &&
|
|
148
|
+
p !== null &&
|
|
149
|
+
p.transform === "typia/lib/transform";
|
|
150
|
+
});
|
|
151
|
+
if (strict && !!core && !!typia)
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
// DO CONFIGURE
|
|
154
|
+
compilerOptions.strict = true;
|
|
155
|
+
if (core === undefined)
|
|
156
|
+
plugins.push(Comment.parse("{\n \"transform\": \"@nestia/core/lib/transform\",\n /**\n * Validate request body.\n * \n * - \"assert\": Use typia.assert() function\n * - \"is\": Use typia.is() function\n * - \"validate\": Use typia.validate() function\n */\n \"validate\": \"assert\",\n\n /**\n * Validate JSON typed response body.\n * \n * - null: Just use JSON.stringify() function, without boosting\n * - \"stringify\": Use typia.stringify() function, but dangerous\n * - \"assert\": Use typia.assertStringify() function\n * - \"is\": Use typia.isStringify() function\n * - \"validate\": Use typia.validateStringify() function\n */\n \"stringify\": \"is\"\n }"));
|
|
157
|
+
if (typia === undefined)
|
|
158
|
+
plugins.push(Comment.parse("{ \"transform\": \"typia/lib/transform\" }"));
|
|
159
|
+
return [4 /*yield*/, fs_1.default.promises.writeFile(args.project, Comment.stringify(config, null, 2))];
|
|
160
|
+
case 3:
|
|
161
|
+
_c.sent();
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
})(PluginConfigurator = exports.PluginConfigurator || (exports.PluginConfigurator = {}));
|
|
168
|
+
//# sourceMappingURL=PluginConfigurator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginConfigurator.js","sourceRoot":"","sources":["../../../src/executable/internal/PluginConfigurator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAoB;AACpB,8CAAwB;AAKxB,IAAiB,kBAAkB,CAwHlC;AAxHD,WAAiB,kBAAkB;IAC/B,SAAsB,SAAS,CAC3B,IAAoB,EACpB,IAA+B;;;;;;;wBAGzB,SAAS,GAAY,IAAI,CAAC,OAAO,CAAC;4BACpC,GAAG,EAAE,IAAI;4BACT,MAAM,EAAE,cAAc;4BACtB,OAAO,EAAE,OAAO;4BAChB,MAAM,EAAE,IAAI;yBACf,CAAC,CAAC;wBAGyB,qBAAM,CAAC;;;;;;4CAE3B,qBAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,EAAA;;4CAA5B,SAA4B,CAAC;4CAC7B,sBAAO,IAAI,EAAC;;;4CAEZ,sBAAO,KAAY,EAAC;;;;iCAE3B,CAAC,EAAE,EAAA;;wBAPE,KAAK,GAAiB,SAOxB;wBAEJ,YAAY;wBACZ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AAK,QAAQ;gCACrB,CAAC,KAAK,IAAI;gCACV,CAAC,CAAC,SAAS,KAAK,4BAA4B;wBAF5C,CAE4C,CACnD,CAAC;wBACI,KAAK,GAAsC,OAAO,CAAC,IAAI,CACzD,UAAC,CAAC;4BACE,OAAA,OAAO,CAAC,KAAK,QAAQ;gCACrB,CAAC,KAAK,IAAI;gCACV,CAAC,CAAC,SAAS,KAAK,qBAAqB;wBAFrC,CAEqC,CAC5C,CAAC;wBACF,IAAI,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK;4BAAE,sBAAO;wBAExC,eAAe;wBACf,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC;wBAC9B,IAAI,IAAI,KAAK,SAAS;4BAClB,OAAO,CAAC,IAAI,CACR,OAAO,CAAC,KAAK,CAAC,y1BAqBZ,CAA0B,CAC/B,CAAC;wBACN,IAAI,KAAK,KAAK,SAAS;4BACnB,OAAO,CAAC,IAAI,CACR,OAAO,CAAC,KAAK,CACT,4CAAwC,CAClB,CAC7B,CAAC;wBACN,qBAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACvB,IAAI,CAAC,OAAQ,EACb,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,EAAA;;wBAHD,SAGC,CAAC;;;;;KACL;AACL,CAAC,EAxHgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAwHlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"dev": "npm run build -- --watch",
|
|
14
14
|
"eslint": "eslint ./**/*.ts",
|
|
15
15
|
"eslint:fix": "eslint ./**/*.ts --fix",
|
|
16
|
+
"package": "npm publish --access public",
|
|
16
17
|
"prettier": "prettier ./**/*.ts --write",
|
|
17
18
|
"test": "node bin/test"
|
|
18
19
|
},
|
|
@@ -38,16 +39,20 @@
|
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
|
|
40
41
|
"@types/express": "^4.17.15",
|
|
42
|
+
"@types/inquirer": "^9.0.3",
|
|
41
43
|
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
42
44
|
"@typescript-eslint/parser": "^5.46.1",
|
|
45
|
+
"commander": "^10.0.0",
|
|
43
46
|
"comment-json": "^4.2.3",
|
|
44
47
|
"eslint-plugin-deprecation": "^1.3.3",
|
|
45
48
|
"git-last-commit": "^1.0.1",
|
|
49
|
+
"inquirer": "^8.2.5",
|
|
46
50
|
"rimraf": "^3.0.2",
|
|
47
51
|
"ts-node": "^10.9.1",
|
|
48
52
|
"tstl": "^2.5.13",
|
|
49
53
|
"ttypescript": "^1.5.15",
|
|
50
|
-
"typescript": "^4.9.
|
|
54
|
+
"typescript": "^4.9.5",
|
|
55
|
+
"typescript-transform-paths": "^3.4.6"
|
|
51
56
|
},
|
|
52
57
|
"dependencies": {
|
|
53
58
|
"@nestia/fetcher": "^1.0.0",
|
|
@@ -58,7 +63,7 @@
|
|
|
58
63
|
"raw-body": "*",
|
|
59
64
|
"reflect-metadata": "*",
|
|
60
65
|
"rxjs": "*",
|
|
61
|
-
"typia": "^3.
|
|
66
|
+
"typia": "^3.5.3"
|
|
62
67
|
},
|
|
63
68
|
"peerDependencies": {
|
|
64
69
|
"ttypescript": ">= 1.5.15",
|
|
@@ -4,16 +4,35 @@ import { ModuleMetadata } from "@nestjs/common/interfaces";
|
|
|
4
4
|
import { Creator } from "../typings/Creator";
|
|
5
5
|
import { load_controllers } from "./internal/load_controller";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Dynamic module.
|
|
9
|
+
*
|
|
10
|
+
* `DynamicModule` is a namespace wrapping a convenient function, which can load
|
|
11
|
+
* controller classes dynamically just by specifying their directory path.
|
|
12
|
+
*
|
|
13
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
14
|
+
*/
|
|
7
15
|
export namespace DynamicModule {
|
|
16
|
+
/**
|
|
17
|
+
* Mount dynamic module.
|
|
18
|
+
*
|
|
19
|
+
* Constructs a module instance with directory path of controller classes.
|
|
20
|
+
*
|
|
21
|
+
* Every controller classes in the target directory would be dynamically mounted.
|
|
22
|
+
*
|
|
23
|
+
* @param path Path of controllers
|
|
24
|
+
* @param metadata Addtional metadata except controllers
|
|
25
|
+
* @returns module instance
|
|
26
|
+
*/
|
|
8
27
|
export async function mount(
|
|
9
28
|
path: string,
|
|
10
|
-
|
|
29
|
+
metadata: Omit<ModuleMetadata, "controllers"> = {},
|
|
11
30
|
): Promise<object> {
|
|
12
31
|
// LOAD CONTROLLERS
|
|
13
32
|
const controllers: Creator<object>[] = await load_controllers(path);
|
|
14
33
|
|
|
15
34
|
// RETURN WITH DECORATING
|
|
16
|
-
@Module({ ...
|
|
35
|
+
@Module({ ...metadata, controllers })
|
|
17
36
|
class NestiaModule {}
|
|
18
37
|
return NestiaModule;
|
|
19
38
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "@nestjs/common";
|
|
7
7
|
import type express from "express";
|
|
8
8
|
import raw from "raw-body";
|
|
9
|
+
|
|
9
10
|
import { assert, is, validate } from "typia";
|
|
10
11
|
|
|
11
12
|
import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
|
|
@@ -17,14 +18,15 @@ import { validate_request_body } from "./internal/validate_request_body";
|
|
|
17
18
|
/**
|
|
18
19
|
* Encrypted body decorator.
|
|
19
20
|
*
|
|
20
|
-
* `EncryptedBody` is a decorator function getting
|
|
21
|
-
* been encrypted by AES-128/256 algorithm. Also,
|
|
22
|
-
* data type through
|
|
23
|
-
* [
|
|
24
|
-
*
|
|
25
|
-
* data is not following the promised type.
|
|
21
|
+
* `EncryptedBody` is a decorator function getting `application/json` typed data from
|
|
22
|
+
* requeset body which has been encrypted by AES-128/256 algorithm. Also,
|
|
23
|
+
* `EncyrptedBody` validates the request body data type through
|
|
24
|
+
* [typia](https://github.com/samchon/typia) ad the validation speed is
|
|
25
|
+
* maximum 15,000x times faster than `class-validator`.
|
|
26
26
|
*
|
|
27
|
-
* For reference,
|
|
27
|
+
* For reference, when the request body data is not following the promised type `T`,
|
|
28
|
+
* `BadRequestException` error (status code: 400) would be thrown. Also,
|
|
29
|
+
* `EncryptedRoute` decrypts request body using those options.
|
|
28
30
|
*
|
|
29
31
|
* - AES-128/256
|
|
30
32
|
* - CBC mode
|
|
@@ -34,7 +36,9 @@ import { validate_request_body } from "./internal/validate_request_body";
|
|
|
34
36
|
* @return Parameter decorator
|
|
35
37
|
* @author Jeongho Nam - https://github.com/samchon
|
|
36
38
|
*/
|
|
37
|
-
export function EncryptedBody<T>(
|
|
39
|
+
export function EncryptedBody<T>(
|
|
40
|
+
validator?: IRequestBodyValidator<T>,
|
|
41
|
+
): ParameterDecorator {
|
|
38
42
|
const checker = validate_request_body("EncryptedBody")(validator);
|
|
39
43
|
return createParamDecorator(async function EncryptedBody(
|
|
40
44
|
_unknown: any,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { HttpArgumentsHost } from "@nestjs/common/interfaces";
|
|
15
15
|
import express from "express";
|
|
16
16
|
import { Observable, catchError, map } from "rxjs";
|
|
17
|
+
|
|
17
18
|
import {
|
|
18
19
|
assertStringify,
|
|
19
20
|
isStringify,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
|
|
25
26
|
import { Singleton } from "../utils/Singleton";
|
|
26
27
|
import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
|
|
28
|
+
import { TransformError } from "./internal/TransformError";
|
|
27
29
|
import { get_path_and_stringify } from "./internal/get_path_and_stringify";
|
|
28
30
|
import { headers_to_object } from "./internal/headers_to_object";
|
|
29
31
|
import { route_error } from "./internal/route_error";
|
|
@@ -32,21 +34,20 @@ import { route_error } from "./internal/route_error";
|
|
|
32
34
|
* Encrypted router decorator functions.
|
|
33
35
|
*
|
|
34
36
|
* `EncryptedRoute` is a module containing router decorator functions which encrypts
|
|
35
|
-
* response body data through AES-128/
|
|
36
|
-
*
|
|
37
|
-
* [
|
|
37
|
+
* response body data through AES-128/256 encryption. Furthermore, they can boost
|
|
38
|
+
* up JSON string conversion speed about 50x times faster than `class-transformer`,
|
|
39
|
+
* even type safe through [typia](https://github.com/samchon/typia).
|
|
38
40
|
*
|
|
39
|
-
* For reference, `EncryptedRoute`
|
|
41
|
+
* For reference, router functions of `EncryptedRoute` can convert custom error classes
|
|
42
|
+
* to regular {@link nest.HttpException} class automatically, through
|
|
43
|
+
* {@link ExceptionManager}. Also, `EncryptedRoute` encrypts response body using those
|
|
44
|
+
* options.
|
|
40
45
|
*
|
|
41
46
|
* - AES-128/256
|
|
42
47
|
* - CBC mode
|
|
43
48
|
* - PKCS #5 Padding
|
|
44
49
|
* - Base64 Encoding
|
|
45
50
|
*
|
|
46
|
-
* Also, router functions in `EncryptedRoute` can convert custom error classes to the
|
|
47
|
-
* regular {@link nest.HttpException} class automatically, through
|
|
48
|
-
* {@link ExceptionManager}.
|
|
49
|
-
*
|
|
50
51
|
* @author Jeongho Nam - https://github.com/samchon
|
|
51
52
|
*/
|
|
52
53
|
export namespace EncryptedRoute {
|
|
@@ -155,9 +156,7 @@ class EncryptedRouteInterceptor implements NestInterceptor {
|
|
|
155
156
|
context.getClass(),
|
|
156
157
|
);
|
|
157
158
|
if (!param)
|
|
158
|
-
throw
|
|
159
|
-
`Error on nestia.core.EncryptedRoute.${this.method}(): no encryption password is given.`,
|
|
160
|
-
);
|
|
159
|
+
throw TransformError(`EncryptedRoute.${this.method}`);
|
|
161
160
|
|
|
162
161
|
const headers: Singleton<Record<string, string>> =
|
|
163
162
|
new Singleton(() => {
|
|
@@ -5,19 +5,22 @@ import {
|
|
|
5
5
|
} from "@nestjs/common";
|
|
6
6
|
import type express from "express";
|
|
7
7
|
import raw from "raw-body";
|
|
8
|
+
|
|
8
9
|
import { assert, is, validate } from "typia";
|
|
9
10
|
|
|
10
11
|
import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
|
|
11
12
|
import { validate_request_body } from "./internal/validate_request_body";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Type safe body decorator.
|
|
16
|
+
*
|
|
17
|
+
* `TypedBody` is a decoratur function getting `application/json` typed data from
|
|
18
|
+
* request body. Also, it validates the request body data type through
|
|
19
|
+
* [typia](https://github.com/samchon/typia) and the validation speed is
|
|
20
|
+
* maximum 15,000x times faster than `class-validator`.
|
|
15
21
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* [`typia.assert()`](https://github.com/samchon/typia#runtime-type-checkers)
|
|
19
|
-
* function and throws `BadRequestException` error (status code: 400), if the JSON
|
|
20
|
-
* data is not following the promised type.
|
|
22
|
+
* For reference, when the request body data is not following the promised type `T`,
|
|
23
|
+
* `BadRequestException` error (status code: 400) would be thrown.
|
|
21
24
|
*
|
|
22
25
|
* @param validator Custom validator if required. Default is `typia.assert()`
|
|
23
26
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
import type express from "express";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* URL parameter decorator
|
|
9
|
+
* Type safe URL parameter decorator.
|
|
10
10
|
*
|
|
11
|
-
* `TypedParam` is a decorator function getting specific typed parameter from the
|
|
12
|
-
* request URL. It's almost same with the {@link nest.Param}, but `TypedParam`
|
|
13
|
-
* the parameter type manually. Beside, the {@link nest.Param} always
|
|
14
|
-
* parameters as string type.
|
|
11
|
+
* `TypedParam` is a decorator function getting specific typed parameter from the
|
|
12
|
+
* HTTP request URL. It's almost same with the {@link nest.Param}, but `TypedParam`
|
|
13
|
+
* can specify the parameter type manually. Beside, the {@link nest.Param} always
|
|
14
|
+
* parses all of the parameters as string type.
|
|
15
15
|
*
|
|
16
16
|
* ```typescript
|
|
17
17
|
* \@TypedRoute.Get("shopping/sales/:section/:id/:paused")
|
|
@@ -33,7 +33,7 @@ export function TypedParam(
|
|
|
33
33
|
name: string,
|
|
34
34
|
type: "boolean" | "number" | "string" | "uuid" = "string",
|
|
35
35
|
nullable: boolean = false,
|
|
36
|
-
) {
|
|
36
|
+
): ParameterDecorator {
|
|
37
37
|
return createParamDecorator(function TypedParam(
|
|
38
38
|
{}: any,
|
|
39
39
|
ctx: ExecutionContext,
|