nestia 2.1.0-dev.20220414 → 2.1.0-dev.20220430
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/.github/workflows/build.yml +2 -4
- package/README.md +84 -14
- package/{src/bundle → bundle}/HttpError.ts +0 -0
- package/{src/bundle → bundle}/IConnection.ts +0 -0
- package/{src/bundle → bundle}/Primitive.ts +0 -0
- package/{src/bundle → bundle}/__internal/AesPkcs5.ts +0 -0
- package/{src/bundle → bundle}/__internal/Fetcher.ts +0 -0
- package/lib/IConfiguration.d.ts +71 -0
- package/lib/IConfiguration.d.ts.map +1 -0
- package/lib/IConfiguration.js +3 -0
- package/lib/NestiaApplication.d.ts +12 -0
- package/lib/NestiaApplication.d.ts.map +1 -0
- package/lib/NestiaApplication.js +340 -0
- package/lib/analyses/ControllerAnalyzer.d.ts +7 -0
- package/lib/analyses/ControllerAnalyzer.d.ts.map +1 -0
- package/lib/analyses/ControllerAnalyzer.js +191 -0
- package/lib/analyses/GenericAnalyzer.d.ts +6 -0
- package/lib/analyses/GenericAnalyzer.d.ts.map +1 -0
- package/lib/analyses/GenericAnalyzer.js +100 -0
- package/lib/analyses/ImportAnalyzer.d.ts +14 -0
- package/lib/analyses/ImportAnalyzer.d.ts.map +1 -0
- package/lib/analyses/ImportAnalyzer.js +79 -0
- package/lib/analyses/ReflectAnalyzer.d.ts +5 -0
- package/lib/analyses/ReflectAnalyzer.d.ts.map +1 -0
- package/lib/analyses/ReflectAnalyzer.js +313 -0
- package/lib/analyses/SourceFinder.d.ts +5 -0
- package/lib/analyses/SourceFinder.d.ts.map +1 -0
- package/lib/analyses/SourceFinder.js +260 -0
- package/lib/executable/internal/CompilerOptions.d.ts +14 -0
- package/lib/executable/internal/CompilerOptions.d.ts.map +1 -0
- package/lib/executable/internal/CompilerOptions.js +126 -0
- package/lib/executable/internal/NestiaCommand.d.ts +5 -0
- package/lib/executable/internal/NestiaCommand.d.ts.map +1 -0
- package/lib/executable/internal/NestiaCommand.js +228 -0
- package/lib/executable/internal/NestiaConfig.d.ts +5 -0
- package/lib/executable/internal/NestiaConfig.d.ts.map +1 -0
- package/lib/executable/internal/NestiaConfig.js +277 -0
- package/lib/executable/internal/nestia.config.getter.d.ts +2 -0
- package/lib/executable/internal/nestia.config.getter.d.ts.map +1 -0
- package/lib/executable/internal/nestia.config.getter.js +60 -0
- package/lib/executable/nestia.d.ts +3 -0
- package/lib/executable/nestia.d.ts.map +1 -0
- package/lib/executable/nestia.js +129 -0
- package/lib/generates/FileGenerator.d.ts +6 -0
- package/lib/generates/FileGenerator.d.ts.map +1 -0
- package/lib/generates/FileGenerator.js +326 -0
- package/lib/generates/FunctionGenerator.d.ts +6 -0
- package/lib/generates/FunctionGenerator.d.ts.map +1 -0
- package/lib/generates/FunctionGenerator.js +217 -0
- package/lib/generates/SdkGenerator.d.ts +8 -0
- package/lib/generates/SdkGenerator.d.ts.map +1 -0
- package/lib/generates/SdkGenerator.js +128 -0
- package/lib/generates/SwaggerGenerator.d.ts +7 -0
- package/lib/generates/SwaggerGenerator.d.ts.map +1 -0
- package/lib/generates/SwaggerGenerator.js +258 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +28 -0
- package/lib/module.d.ts +3 -0
- package/lib/module.d.ts.map +1 -0
- package/lib/module.js +19 -0
- package/{src/structures/IController.ts → lib/structures/IController.d.ts} +6 -13
- package/lib/structures/IController.d.ts.map +1 -0
- package/lib/structures/IController.js +3 -0
- package/{src/structures/IRoute.ts → lib/structures/IRoute.d.ts} +8 -13
- package/lib/structures/IRoute.d.ts.map +1 -0
- package/lib/structures/IRoute.js +3 -0
- package/lib/structures/ISwagger.d.ts +36 -0
- package/lib/structures/ISwagger.d.ts.map +1 -0
- package/lib/structures/ISwagger.js +3 -0
- package/lib/structures/IType.d.ts +6 -0
- package/lib/structures/IType.d.ts.map +1 -0
- package/lib/structures/IType.js +3 -0
- package/lib/structures/MethodType.d.ts +5 -0
- package/lib/structures/MethodType.d.ts.map +1 -0
- package/lib/structures/MethodType.js +8 -0
- package/lib/structures/ParamCategory.d.ts +2 -0
- package/lib/structures/ParamCategory.d.ts.map +1 -0
- package/lib/structures/ParamCategory.js +3 -0
- package/lib/utils/ArrayUtil.d.ts +6 -0
- package/lib/utils/ArrayUtil.d.ts.map +1 -0
- package/lib/utils/ArrayUtil.js +144 -0
- package/lib/utils/DirectoryUtil.d.ts +6 -0
- package/lib/utils/DirectoryUtil.d.ts.map +1 -0
- package/lib/utils/DirectoryUtil.js +190 -0
- package/lib/utils/ImportDictionary.d.ts +7 -0
- package/lib/utils/ImportDictionary.d.ts.map +1 -0
- package/lib/utils/ImportDictionary.js +83 -0
- package/lib/utils/MapUtil.d.ts +4 -0
- package/lib/utils/MapUtil.d.ts.map +1 -0
- package/lib/utils/MapUtil.js +16 -0
- package/lib/utils/StringUtil.d.ts +4 -0
- package/lib/utils/StringUtil.d.ts.map +1 -0
- package/lib/utils/StringUtil.js +13 -0
- package/package.json +17 -10
- package/src/IConfiguration.ts +0 -17
- package/src/NestiaApplication.ts +0 -96
- package/src/analyses/ControllerAnalyzer.ts +0 -154
- package/src/analyses/GenericAnalyzer.ts +0 -52
- package/src/analyses/ImportAnalyzer.ts +0 -93
- package/src/analyses/ReflectAnalyzer.ts +0 -221
- package/src/analyses/SourceFinder.ts +0 -73
- package/src/bin/nestia.ts +0 -125
- package/src/executable/sdk.ts +0 -89
- package/src/generates/FileGenerator.ts +0 -150
- package/src/generates/FunctionGenerator.ts +0 -201
- package/src/generates/SdkGenerator.ts +0 -39
- package/src/internal/CompilerOptions.ts +0 -142
- package/src/structures/MethodType.ts +0 -6
- package/src/structures/ParamCategory.ts +0 -1
- package/src/utils/ArrayUtil.ts +0 -26
- package/src/utils/DirectoryUtil.ts +0 -48
- package/src/utils/ImportDictionary.ts +0 -44
- package/src/utils/StringUtil.ts +0 -10
- package/src/utils/stripJsonComments.ts +0 -79
- package/tsconfig.json +0 -82
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __values = (this && this.__values) || function(o) {
|
|
14
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
15
|
+
if (m) return m.call(o);
|
|
16
|
+
if (o && typeof o.length === "number") return {
|
|
17
|
+
next: function () {
|
|
18
|
+
if (o && i >= o.length) o = void 0;
|
|
19
|
+
return { value: o && o[i++], done: !o };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
23
|
+
};
|
|
24
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
+
if (!m) return o;
|
|
27
|
+
var i = m.call(o), r, ar = [], e;
|
|
28
|
+
try {
|
|
29
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
+
}
|
|
31
|
+
catch (error) { e = { error: error }; }
|
|
32
|
+
finally {
|
|
33
|
+
try {
|
|
34
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
+
}
|
|
36
|
+
finally { if (e) throw e.error; }
|
|
37
|
+
}
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.CompilerOptions = void 0;
|
|
42
|
+
var nestia_fetcher_1 = require("nestia-fetcher");
|
|
43
|
+
var CompilerOptions;
|
|
44
|
+
(function (CompilerOptions) {
|
|
45
|
+
/* -----------------------------------------------------------
|
|
46
|
+
DEFAULT VALUES
|
|
47
|
+
----------------------------------------------------------- */
|
|
48
|
+
var ESSENTIAL_OPTIONS = {
|
|
49
|
+
types: [
|
|
50
|
+
"node",
|
|
51
|
+
"reflect-metadata"
|
|
52
|
+
],
|
|
53
|
+
noEmit: true,
|
|
54
|
+
esModuleInterop: true,
|
|
55
|
+
experimentalDecorators: true,
|
|
56
|
+
emitDecoratorMetadata: true
|
|
57
|
+
};
|
|
58
|
+
CompilerOptions.DEFAULT_OPTIONS = __assign(__assign({}, ESSENTIAL_OPTIONS), { target: "es5", module: "commonjs" });
|
|
59
|
+
function emend(options, assert) {
|
|
60
|
+
var e_1, _a;
|
|
61
|
+
try {
|
|
62
|
+
// EMEND PROPERTIES
|
|
63
|
+
for (var _b = __values(Object.entries(ESSENTIAL_OPTIONS)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
64
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
65
|
+
if (options[key] instanceof Array && value instanceof Array)
|
|
66
|
+
merge_array(options[key], value);
|
|
67
|
+
else if (typeof options[key] === "object")
|
|
68
|
+
Object.assign(options[key], value);
|
|
69
|
+
else
|
|
70
|
+
options[key] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
74
|
+
finally {
|
|
75
|
+
try {
|
|
76
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
77
|
+
}
|
|
78
|
+
finally { if (e_1) throw e_1.error; }
|
|
79
|
+
}
|
|
80
|
+
//----
|
|
81
|
+
// CONSTRUCT PLUGINS
|
|
82
|
+
//----
|
|
83
|
+
// INITALIZE PLUGINS
|
|
84
|
+
if (!options.plugins || !(options.plugins instanceof Array))
|
|
85
|
+
options.plugins = [];
|
|
86
|
+
var transformed = [];
|
|
87
|
+
var plugins = options.plugins;
|
|
88
|
+
var emplace = function (input) {
|
|
89
|
+
var found = plugins.find(function (p) { return nestia_fetcher_1.Primitive.equal_to(p, input); });
|
|
90
|
+
if (found === undefined)
|
|
91
|
+
plugins.push(input);
|
|
92
|
+
transformed.push(true);
|
|
93
|
+
};
|
|
94
|
+
if (assert === true)
|
|
95
|
+
emplace({
|
|
96
|
+
transform: "typescript-is/lib/transform-inline/transformer"
|
|
97
|
+
});
|
|
98
|
+
if (options.paths && Object.entries(options.paths).length !== 0)
|
|
99
|
+
emplace({ transform: "typescript-transform-paths" });
|
|
100
|
+
return [!!transformed.length, !!options.baseUrl];
|
|
101
|
+
}
|
|
102
|
+
CompilerOptions.emend = emend;
|
|
103
|
+
function merge_array(origin, must) {
|
|
104
|
+
var e_2, _a;
|
|
105
|
+
var _loop_1 = function (m) {
|
|
106
|
+
var found = origin.find(function (elem) { return elem === m; });
|
|
107
|
+
if (found !== undefined)
|
|
108
|
+
return "continue";
|
|
109
|
+
origin.push(m);
|
|
110
|
+
};
|
|
111
|
+
try {
|
|
112
|
+
for (var must_1 = __values(must), must_1_1 = must_1.next(); !must_1_1.done; must_1_1 = must_1.next()) {
|
|
113
|
+
var m = must_1_1.value;
|
|
114
|
+
_loop_1(m);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
118
|
+
finally {
|
|
119
|
+
try {
|
|
120
|
+
if (must_1_1 && !must_1_1.done && (_a = must_1.return)) _a.call(must_1);
|
|
121
|
+
}
|
|
122
|
+
finally { if (e_2) throw e_2.error; }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
})(CompilerOptions = exports.CompilerOptions || (exports.CompilerOptions = {}));
|
|
126
|
+
//# sourceMappingURL=CompilerOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NestiaCommand.d.ts","sourceRoot":"","sources":["../../../src/executable/internal/NestiaCommand.ts"],"names":[],"mappings":"AAuBA,yBAAiB,aAAa,CAC9B;IACI,SAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAa3E;IAED,SAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB/E;CAqGJ"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
65
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
+
if (ar || !(i in from)) {
|
|
68
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
+
ar[i] = from[i];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
+
};
|
|
74
|
+
var __values = (this && this.__values) || function(o) {
|
|
75
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
76
|
+
if (m) return m.call(o);
|
|
77
|
+
if (o && typeof o.length === "number") return {
|
|
78
|
+
next: function () {
|
|
79
|
+
if (o && i >= o.length) o = void 0;
|
|
80
|
+
return { value: o && o[i++], done: !o };
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
84
|
+
};
|
|
85
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
86
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
|
+
};
|
|
88
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
+
exports.NestiaCommand = void 0;
|
|
90
|
+
var cli_1 = __importDefault(require("cli"));
|
|
91
|
+
var fs_1 = __importDefault(require("fs"));
|
|
92
|
+
var jsonc_simple_parser_1 = __importDefault(require("jsonc-simple-parser"));
|
|
93
|
+
var WorkerConnector_1 = require("tgrid/protocols/workers/WorkerConnector");
|
|
94
|
+
var NestiaApplication_1 = require("../../NestiaApplication");
|
|
95
|
+
var NestiaCommand;
|
|
96
|
+
(function (NestiaCommand) {
|
|
97
|
+
function sdk(elements, pure) {
|
|
98
|
+
if (pure === void 0) { pure = true; }
|
|
99
|
+
return main(function (app) { return app.sdk(); }, {
|
|
100
|
+
assign: function (config, output) { return config.output = output; },
|
|
101
|
+
validate: function (config) { return !!config.output; },
|
|
102
|
+
location: function (config) { return config.output; },
|
|
103
|
+
}, elements, pure);
|
|
104
|
+
}
|
|
105
|
+
NestiaCommand.sdk = sdk;
|
|
106
|
+
function swagger(elements, pure) {
|
|
107
|
+
if (pure === void 0) { pure = true; }
|
|
108
|
+
return main(function (app) { return app.swagger(); }, {
|
|
109
|
+
assign: function (config, output) {
|
|
110
|
+
if (!config.swagger)
|
|
111
|
+
config.swagger = { output: output };
|
|
112
|
+
else
|
|
113
|
+
config.swagger.output = output;
|
|
114
|
+
},
|
|
115
|
+
validate: function (config) { return !!config.swagger && !!config.swagger.output; },
|
|
116
|
+
location: function (config) { return config.swagger.output; },
|
|
117
|
+
}, elements, pure);
|
|
118
|
+
}
|
|
119
|
+
NestiaCommand.swagger = swagger;
|
|
120
|
+
function main(task, output, elements, pure) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var command, inputs, elements_1, elements_1_1, arg;
|
|
123
|
+
var e_1, _a;
|
|
124
|
+
return __generator(this, function (_b) {
|
|
125
|
+
switch (_b.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
if (pure === false)
|
|
128
|
+
cli_1.default.setArgv(__spreadArray([
|
|
129
|
+
process.argv[0],
|
|
130
|
+
process.argv[1],
|
|
131
|
+
"nestia"
|
|
132
|
+
], __read(elements), false));
|
|
133
|
+
command = cli_1.default.parse({
|
|
134
|
+
exclude: ["e", "Something to exclude", "string", null],
|
|
135
|
+
out: ["o", "Output path of the SDK files", "string", null],
|
|
136
|
+
});
|
|
137
|
+
inputs = [];
|
|
138
|
+
try {
|
|
139
|
+
for (elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
140
|
+
arg = elements_1_1.value;
|
|
141
|
+
if (arg[0] === "-")
|
|
142
|
+
break;
|
|
143
|
+
inputs.push(arg);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
147
|
+
finally {
|
|
148
|
+
try {
|
|
149
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
150
|
+
}
|
|
151
|
+
finally { if (e_1) throw e_1.error; }
|
|
152
|
+
}
|
|
153
|
+
return [4 /*yield*/, generate(task, inputs, command, output)];
|
|
154
|
+
case 1:
|
|
155
|
+
_b.sent();
|
|
156
|
+
return [2 /*return*/];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function generate(task, include, command, output) {
|
|
162
|
+
var _a;
|
|
163
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
+
var config, content, options, app;
|
|
165
|
+
return __generator(this, function (_b) {
|
|
166
|
+
switch (_b.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, get_nestia_config(output.validate)];
|
|
168
|
+
case 1:
|
|
169
|
+
config = (_a = _b.sent()) !== null && _a !== void 0 ? _a : parse_cli(include, command, output);
|
|
170
|
+
if (!(fs_1.default.existsSync("tsconfig.json") === true)) return [3 /*break*/, 3];
|
|
171
|
+
return [4 /*yield*/, fs_1.default.promises.readFile("tsconfig.json", "utf8")];
|
|
172
|
+
case 2:
|
|
173
|
+
content = _b.sent();
|
|
174
|
+
options = jsonc_simple_parser_1.default.parse(content).compilerOptions;
|
|
175
|
+
config.compilerOptions = __assign(__assign({}, options), (config.compilerOptions || {}));
|
|
176
|
+
_b.label = 3;
|
|
177
|
+
case 3:
|
|
178
|
+
app = new NestiaApplication_1.NestiaApplication(config);
|
|
179
|
+
return [4 /*yield*/, task(app)];
|
|
180
|
+
case 4:
|
|
181
|
+
_b.sent();
|
|
182
|
+
return [2 /*return*/];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function get_nestia_config(validate) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var connector, driver, config;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
connector = new WorkerConnector_1.WorkerConnector(null, null, "process");
|
|
194
|
+
return [4 /*yield*/, connector.connect("".concat(__dirname, "/nestia.config.getter.js"))];
|
|
195
|
+
case 1:
|
|
196
|
+
_a.sent();
|
|
197
|
+
return [4 /*yield*/, connector.getDriver()];
|
|
198
|
+
case 2:
|
|
199
|
+
driver = _a.sent();
|
|
200
|
+
return [4 /*yield*/, driver.get()];
|
|
201
|
+
case 3:
|
|
202
|
+
config = _a.sent();
|
|
203
|
+
return [4 /*yield*/, connector.close()];
|
|
204
|
+
case 4:
|
|
205
|
+
_a.sent();
|
|
206
|
+
if (config !== null && validate(config) === false)
|
|
207
|
+
throw new Error("Error on NestiaCommand.main(): output path is not specified in the \"nestia.config.ts\".");
|
|
208
|
+
return [2 /*return*/, config];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function parse_cli(include, command, output) {
|
|
214
|
+
if (command.out === null)
|
|
215
|
+
throw new Error("Output directory is not specified. Add the \"--out <output_directory>\" option.");
|
|
216
|
+
var config = {
|
|
217
|
+
input: {
|
|
218
|
+
include: include,
|
|
219
|
+
exclude: command.exclude
|
|
220
|
+
? [command.exclude]
|
|
221
|
+
: undefined
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
output.assign(config, command.out);
|
|
225
|
+
return config;
|
|
226
|
+
}
|
|
227
|
+
})(NestiaCommand = exports.NestiaCommand || (exports.NestiaCommand = {}));
|
|
228
|
+
//# sourceMappingURL=NestiaCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NestiaConfig.d.ts","sourceRoot":"","sources":["../../../src/executable/internal/NestiaConfig.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,yBAAiB,YAAY,CAC7B;IACI,SAAgB,GAAG,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAGpD;CAuCJ"}
|
|
@@ -0,0 +1,277 @@
|
|
|
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 (_) 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 __values = (this && this.__values) || function(o) {
|
|
62
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
63
|
+
if (m) return m.call(o);
|
|
64
|
+
if (o && typeof o.length === "number") return {
|
|
65
|
+
next: function () {
|
|
66
|
+
if (o && i >= o.length) o = void 0;
|
|
67
|
+
return { value: o && o[i++], done: !o };
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.NestiaConfig = void 0;
|
|
74
|
+
var fs = __importStar(require("fs"));
|
|
75
|
+
var path = __importStar(require("path"));
|
|
76
|
+
var runner = __importStar(require("ts-node"));
|
|
77
|
+
var InvalidArgument_1 = require("tstl/exception/InvalidArgument");
|
|
78
|
+
var nestia_fetcher_1 = require("nestia-fetcher");
|
|
79
|
+
var Singleton_1 = require("tstl/thread/Singleton");
|
|
80
|
+
var typescript_is_1 = require("typescript-is");
|
|
81
|
+
var NestiaConfig;
|
|
82
|
+
(function (NestiaConfig) {
|
|
83
|
+
var _this = this;
|
|
84
|
+
function get() {
|
|
85
|
+
return singleton.get();
|
|
86
|
+
}
|
|
87
|
+
NestiaConfig.get = get;
|
|
88
|
+
function assert(config) {
|
|
89
|
+
(0, typescript_is_1.assertType)(config, function (object) { var path = ["config"]; function _undefined(object) { ; if (object !== undefined)
|
|
90
|
+
return { message: "validation failed at " + path.join(".") + ": expected undefined", path: path.slice(), reason: { type: "undefined" } };
|
|
91
|
+
else
|
|
92
|
+
return null; } function _string(object) { ; if (typeof object !== "string")
|
|
93
|
+
return { message: "validation failed at " + path.join(".") + ": expected a string", path: path.slice(), reason: { type: "string" } };
|
|
94
|
+
else
|
|
95
|
+
return null; } function _null(object) { ; if (object !== null)
|
|
96
|
+
return { message: "validation failed at " + path.join(".") + ": expected null", path: path.slice(), reason: { type: "null" } };
|
|
97
|
+
else
|
|
98
|
+
return null; } function su__undefined__string_eu(object) {
|
|
99
|
+
var e_1, _a;
|
|
100
|
+
var conditions = [_undefined, _string];
|
|
101
|
+
try {
|
|
102
|
+
for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
|
|
103
|
+
var condition = conditions_1_1.value;
|
|
104
|
+
var error = condition(object);
|
|
105
|
+
if (!error)
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
110
|
+
finally {
|
|
111
|
+
try {
|
|
112
|
+
if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
|
|
113
|
+
}
|
|
114
|
+
finally { if (e_1) throw e_1.error; }
|
|
115
|
+
}
|
|
116
|
+
return { message: "validation failed at " + path.join(".") + ": there are no valid alternatives", path: path.slice(), reason: { type: "union" } };
|
|
117
|
+
} function _false(object) { ; if (object !== false)
|
|
118
|
+
return { message: "validation failed at " + path.join(".") + ": expected false", path: path.slice(), reason: { type: "boolean-literal", value: false } };
|
|
119
|
+
else
|
|
120
|
+
return null; } function _true(object) { ; if (object !== true)
|
|
121
|
+
return { message: "validation failed at " + path.join(".") + ": expected true", path: path.slice(), reason: { type: "boolean-literal", value: true } };
|
|
122
|
+
else
|
|
123
|
+
return null; } function su__undefined__5__6_eu(object) {
|
|
124
|
+
var e_2, _a;
|
|
125
|
+
var conditions = [_undefined, _false, _true];
|
|
126
|
+
try {
|
|
127
|
+
for (var conditions_2 = __values(conditions), conditions_2_1 = conditions_2.next(); !conditions_2_1.done; conditions_2_1 = conditions_2.next()) {
|
|
128
|
+
var condition = conditions_2_1.value;
|
|
129
|
+
var error = condition(object);
|
|
130
|
+
if (!error)
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
135
|
+
finally {
|
|
136
|
+
try {
|
|
137
|
+
if (conditions_2_1 && !conditions_2_1.done && (_a = conditions_2.return)) _a.call(conditions_2);
|
|
138
|
+
}
|
|
139
|
+
finally { if (e_2) throw e_2.error; }
|
|
140
|
+
}
|
|
141
|
+
return { message: "validation failed at " + path.join(".") + ": there are no valid alternatives", path: path.slice(), reason: { type: "union" } };
|
|
142
|
+
} function _8(object) { ; if (typeof object !== "object" || object === null || Array.isArray(object))
|
|
143
|
+
return { message: "validation failed at " + path.join(".") + ": expected an object", path: path.slice(), reason: { type: "object" } }; {
|
|
144
|
+
if ("output" in object) {
|
|
145
|
+
path.push("output");
|
|
146
|
+
var error = _string(object["output"]);
|
|
147
|
+
path.pop();
|
|
148
|
+
if (error)
|
|
149
|
+
return error;
|
|
150
|
+
}
|
|
151
|
+
else
|
|
152
|
+
return { message: "validation failed at " + path.join(".") + ": expected 'output' in object", path: path.slice(), reason: { type: "missing-property", property: "output" } };
|
|
153
|
+
} return null; } function su__undefined__8_eu(object) {
|
|
154
|
+
var e_3, _a;
|
|
155
|
+
var conditions = [_undefined, _8];
|
|
156
|
+
try {
|
|
157
|
+
for (var conditions_3 = __values(conditions), conditions_3_1 = conditions_3.next(); !conditions_3_1.done; conditions_3_1 = conditions_3.next()) {
|
|
158
|
+
var condition = conditions_3_1.value;
|
|
159
|
+
var error = condition(object);
|
|
160
|
+
if (!error)
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
165
|
+
finally {
|
|
166
|
+
try {
|
|
167
|
+
if (conditions_3_1 && !conditions_3_1.done && (_a = conditions_3.return)) _a.call(conditions_3);
|
|
168
|
+
}
|
|
169
|
+
finally { if (e_3) throw e_3.error; }
|
|
170
|
+
}
|
|
171
|
+
return { message: "validation failed at " + path.join(".") + ": there are no valid alternatives", path: path.slice(), reason: { type: "union" } };
|
|
172
|
+
} function _0(object) { ; if (typeof object !== "object" || object === null || Array.isArray(object))
|
|
173
|
+
return { message: "validation failed at " + path.join(".") + ": expected an object", path: path.slice(), reason: { type: "object" } }; {
|
|
174
|
+
if ("output" in object) {
|
|
175
|
+
path.push("output");
|
|
176
|
+
var error = su__undefined__string_eu(object["output"]);
|
|
177
|
+
path.pop();
|
|
178
|
+
if (error)
|
|
179
|
+
return error;
|
|
180
|
+
}
|
|
181
|
+
} {
|
|
182
|
+
if ("assert" in object) {
|
|
183
|
+
path.push("assert");
|
|
184
|
+
var error = su__undefined__5__6_eu(object["assert"]);
|
|
185
|
+
path.pop();
|
|
186
|
+
if (error)
|
|
187
|
+
return error;
|
|
188
|
+
}
|
|
189
|
+
} {
|
|
190
|
+
if ("json" in object) {
|
|
191
|
+
path.push("json");
|
|
192
|
+
var error = su__undefined__5__6_eu(object["json"]);
|
|
193
|
+
path.pop();
|
|
194
|
+
if (error)
|
|
195
|
+
return error;
|
|
196
|
+
}
|
|
197
|
+
} {
|
|
198
|
+
if ("swagger" in object) {
|
|
199
|
+
path.push("swagger");
|
|
200
|
+
var error = su__undefined__8_eu(object["swagger"]);
|
|
201
|
+
path.pop();
|
|
202
|
+
if (error)
|
|
203
|
+
return error;
|
|
204
|
+
}
|
|
205
|
+
} return null; } return _0(object); });
|
|
206
|
+
if ((0, typescript_is_1.is)(config.input, function (object) { function _string(object) { ; if (typeof object !== "string")
|
|
207
|
+
return {};
|
|
208
|
+
else
|
|
209
|
+
return null; } return _string(object); }) === false
|
|
210
|
+
&& (0, typescript_is_1.is)(config.input, function (object) { function _string(object) { ; if (typeof object !== "string")
|
|
211
|
+
return {};
|
|
212
|
+
else
|
|
213
|
+
return null; } function sa__string_ea_2(object) { ; if (!Array.isArray(object))
|
|
214
|
+
return {}; for (var i = 0; i < object.length; i++) {
|
|
215
|
+
var error = _string(object[i]);
|
|
216
|
+
if (error)
|
|
217
|
+
return error;
|
|
218
|
+
} return null; } return sa__string_ea_2(object); }) === false
|
|
219
|
+
&& (0, typescript_is_1.is)(config.input, function (object) { function _string(object) { ; if (typeof object !== "string")
|
|
220
|
+
return {};
|
|
221
|
+
else
|
|
222
|
+
return null; } function sa__string_ea_3(object) { ; if (!Array.isArray(object))
|
|
223
|
+
return {}; for (var i = 0; i < object.length; i++) {
|
|
224
|
+
var error = _string(object[i]);
|
|
225
|
+
if (error)
|
|
226
|
+
return error;
|
|
227
|
+
} return null; } function _0(object) { ; if (typeof object !== "object" || object === null || Array.isArray(object))
|
|
228
|
+
return {}; {
|
|
229
|
+
if ("include" in object) {
|
|
230
|
+
var error = sa__string_ea_3(object["include"]);
|
|
231
|
+
if (error)
|
|
232
|
+
return error;
|
|
233
|
+
}
|
|
234
|
+
else
|
|
235
|
+
return {};
|
|
236
|
+
} {
|
|
237
|
+
if ("exclude" in object) {
|
|
238
|
+
var error = sa__string_ea_3(object["exclude"]);
|
|
239
|
+
if (error)
|
|
240
|
+
return error;
|
|
241
|
+
}
|
|
242
|
+
} return null; } return _0(object); }) === false)
|
|
243
|
+
throw new InvalidArgument_1.InvalidArgument("Error on NestiaConfig.get(): invalid input type.");
|
|
244
|
+
return config;
|
|
245
|
+
}
|
|
246
|
+
var singleton = new Singleton_1.Singleton(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
247
|
+
var config, trial;
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
if (fs.existsSync("nestia.config.ts") === false)
|
|
252
|
+
return [2 /*return*/, null];
|
|
253
|
+
runner.register({
|
|
254
|
+
emit: false,
|
|
255
|
+
compilerOptions: {
|
|
256
|
+
noEmit: true
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require(path.resolve("nestia.config.ts"))); })];
|
|
260
|
+
case 1:
|
|
261
|
+
config = _a.sent();
|
|
262
|
+
try {
|
|
263
|
+
return [2 /*return*/, assert(nestia_fetcher_1.Primitive.clone(config))];
|
|
264
|
+
}
|
|
265
|
+
catch (exp) {
|
|
266
|
+
trial = config;
|
|
267
|
+
if (trial.default && typeof trial.default === "object")
|
|
268
|
+
return [2 /*return*/, assert(nestia_fetcher_1.Primitive.clone(trial.default))];
|
|
269
|
+
else
|
|
270
|
+
throw exp;
|
|
271
|
+
}
|
|
272
|
+
return [2 /*return*/];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}); });
|
|
276
|
+
})(NestiaConfig = exports.NestiaConfig || (exports.NestiaConfig = {}));
|
|
277
|
+
//# sourceMappingURL=NestiaConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestia.config.getter.d.ts","sourceRoot":"","sources":["../../../src/executable/internal/nestia.config.getter.ts"],"names":[],"mappings":""}
|