nestia 2.0.5 → 2.0.7-dev.20220414
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 +5 -0
- package/{src/IConfiguration.ts → bin/IConfiguration.d.ts} +5 -8
- package/bin/IConfiguration.d.ts.map +1 -0
- package/bin/IConfiguration.js +3 -0
- package/bin/NestiaApplication.d.ts +10 -0
- package/bin/NestiaApplication.d.ts.map +1 -0
- package/bin/NestiaApplication.js +281 -0
- package/bin/analyses/ControllerAnalyzer.d.ts +7 -0
- package/bin/analyses/ControllerAnalyzer.d.ts.map +1 -0
- package/bin/analyses/ControllerAnalyzer.js +186 -0
- package/bin/analyses/GenericAnalyzer.d.ts +6 -0
- package/bin/analyses/GenericAnalyzer.d.ts.map +1 -0
- package/bin/analyses/GenericAnalyzer.js +100 -0
- package/bin/analyses/ImportAnalyzer.d.ts +13 -0
- package/bin/analyses/ImportAnalyzer.d.ts.map +1 -0
- package/bin/analyses/ImportAnalyzer.js +82 -0
- package/bin/analyses/ReflectAnalyzer.d.ts +5 -0
- package/bin/analyses/ReflectAnalyzer.d.ts.map +1 -0
- package/bin/analyses/ReflectAnalyzer.js +307 -0
- package/bin/analyses/SourceFinder.d.ts +5 -0
- package/bin/analyses/SourceFinder.d.ts.map +1 -0
- package/bin/analyses/SourceFinder.js +260 -0
- package/bin/bundle/HttpError.d.ts +2 -0
- package/bin/bundle/HttpError.d.ts.map +1 -0
- package/bin/bundle/HttpError.js +6 -0
- package/bin/bundle/IConnection.d.ts +2 -0
- package/bin/bundle/IConnection.d.ts.map +1 -0
- package/bin/bundle/IConnection.js +3 -0
- package/bin/bundle/Primitive.d.ts +2 -0
- package/bin/bundle/Primitive.d.ts.map +1 -0
- package/bin/bundle/Primitive.js +6 -0
- package/bin/bundle/__internal/AesPkcs5.d.ts +2 -0
- package/bin/bundle/__internal/AesPkcs5.d.ts.map +1 -0
- package/bin/bundle/__internal/AesPkcs5.js +6 -0
- package/bin/bundle/__internal/Fetcher.d.ts +2 -0
- package/bin/bundle/__internal/Fetcher.d.ts.map +1 -0
- package/bin/bundle/__internal/Fetcher.js +6 -0
- package/bin/executable/internal/CompilerOptions.d.ts +13 -0
- package/bin/executable/internal/CompilerOptions.d.ts.map +1 -0
- package/bin/executable/internal/CompilerOptions.js +132 -0
- package/bin/executable/internal/NestiaConfig.d.ts +5 -0
- package/bin/executable/internal/NestiaConfig.d.ts.map +1 -0
- package/bin/executable/internal/NestiaConfig.js +196 -0
- package/bin/executable/internal/nestia.config.getter.d.ts +2 -0
- package/bin/executable/internal/nestia.config.getter.d.ts.map +1 -0
- package/bin/executable/internal/nestia.config.getter.js +60 -0
- package/bin/executable/nestia.d.ts +3 -0
- package/bin/executable/nestia.d.ts.map +1 -0
- package/bin/executable/nestia.js +136 -0
- package/bin/executable/sdk.d.ts +2 -0
- package/bin/executable/sdk.d.ts.map +1 -0
- package/bin/executable/sdk.js +206 -0
- package/bin/generates/FileGenerator.d.ts +6 -0
- package/bin/generates/FileGenerator.d.ts.map +1 -0
- package/bin/generates/FileGenerator.js +302 -0
- package/bin/generates/FunctionGenerator.d.ts +5 -0
- package/bin/generates/FunctionGenerator.d.ts.map +1 -0
- package/bin/generates/FunctionGenerator.js +207 -0
- package/bin/generates/SdkGenerator.d.ts +6 -0
- package/bin/generates/SdkGenerator.d.ts.map +1 -0
- package/bin/generates/SdkGenerator.js +147 -0
- package/bin/index.d.ts +3 -0
- package/bin/index.d.ts.map +1 -0
- package/bin/index.js +28 -0
- package/bin/module.d.ts +3 -0
- package/bin/module.d.ts.map +1 -0
- package/bin/module.js +19 -0
- package/{src/structures/IController.ts → bin/structures/IController.d.ts} +6 -13
- package/bin/structures/IController.d.ts.map +1 -0
- package/bin/structures/IController.js +3 -0
- package/{src/structures/IRoute.ts → bin/structures/IRoute.d.ts} +5 -11
- package/bin/structures/IRoute.d.ts.map +1 -0
- package/bin/structures/IRoute.js +3 -0
- package/bin/structures/MethodType.d.ts +5 -0
- package/bin/structures/MethodType.d.ts.map +1 -0
- package/bin/structures/MethodType.js +8 -0
- package/bin/structures/ParamCategory.d.ts +2 -0
- package/bin/structures/ParamCategory.d.ts.map +1 -0
- package/bin/structures/ParamCategory.js +3 -0
- package/bin/utils/ArrayUtil.d.ts +6 -0
- package/bin/utils/ArrayUtil.d.ts.map +1 -0
- package/bin/utils/ArrayUtil.js +144 -0
- package/bin/utils/DirectoryUtil.d.ts +6 -0
- package/bin/utils/DirectoryUtil.d.ts.map +1 -0
- package/bin/utils/DirectoryUtil.js +190 -0
- package/bin/utils/ImportDictionary.d.ts +7 -0
- package/bin/utils/ImportDictionary.d.ts.map +1 -0
- package/bin/utils/ImportDictionary.js +85 -0
- package/bin/utils/StringUtil.d.ts +4 -0
- package/bin/utils/StringUtil.d.ts.map +1 -0
- package/bin/utils/StringUtil.js +13 -0
- package/bin/utils/stripJsonComments.d.ts +4 -0
- package/bin/utils/stripJsonComments.d.ts.map +1 -0
- package/bin/utils/stripJsonComments.js +76 -0
- package/package.json +14 -10
- package/tsconfig.json +8 -7
- 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 -59
- package/src/bundle/HttpError.ts +0 -1
- package/src/bundle/IConnection.ts +0 -1
- package/src/bundle/Primitive.ts +0 -1
- package/src/bundle/__internal/AesPkcs5.ts +0 -1
- package/src/bundle/__internal/Fetcher.ts +0 -1
- 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/TsConfig.ts +0 -115
- package/src/internal/tsconfig.default.json +0 -81
- 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
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.FunctionGenerator = void 0;
|
|
40
|
+
var Pair_1 = require("tstl/utility/Pair");
|
|
41
|
+
var Vector_1 = require("tstl/container/Vector");
|
|
42
|
+
var FunctionGenerator;
|
|
43
|
+
(function (FunctionGenerator) {
|
|
44
|
+
function generate(assert, route) {
|
|
45
|
+
var query = route.parameters.find(function (param) { return param.category === "query"; });
|
|
46
|
+
var input = route.parameters.find(function (param) { return param.category === "body"; });
|
|
47
|
+
return [head, body, tail]
|
|
48
|
+
.map(function (closure) { return closure(route, query, input, assert); })
|
|
49
|
+
.filter(function (str) { return !!str; })
|
|
50
|
+
.join("\n");
|
|
51
|
+
}
|
|
52
|
+
FunctionGenerator.generate = generate;
|
|
53
|
+
/* ---------------------------------------------------------
|
|
54
|
+
BODY
|
|
55
|
+
--------------------------------------------------------- */
|
|
56
|
+
function body(route, query, input, assert) {
|
|
57
|
+
// FETCH ARGUMENTS WITH REQUST BODY
|
|
58
|
+
var parameters = filter_parameters(route, query);
|
|
59
|
+
var fetchArguments = [
|
|
60
|
+
"connection",
|
|
61
|
+
"".concat(route.name, ".ENCRYPTED"),
|
|
62
|
+
"".concat(route.name, ".METHOD"),
|
|
63
|
+
"".concat(route.name, ".path(").concat(parameters.map(function (p) { return p.name; }).join(", "), ")")
|
|
64
|
+
];
|
|
65
|
+
if (input !== undefined)
|
|
66
|
+
fetchArguments.push(input.name);
|
|
67
|
+
var assertions = assert === true && route.parameters.length !== 0
|
|
68
|
+
? route.parameters
|
|
69
|
+
.map(function (param) { return " assertType<typeof ".concat(param.name, ">(").concat(param.name, ");"); })
|
|
70
|
+
.join("\n") + "\n\n"
|
|
71
|
+
: "";
|
|
72
|
+
// RETURNS WITH FINALIZATION
|
|
73
|
+
return "{\n"
|
|
74
|
+
+ assertions
|
|
75
|
+
+ " return Fetcher.fetch\n"
|
|
76
|
+
+ " (\n"
|
|
77
|
+
+ fetchArguments.map(function (param) { return " ".concat(param); }).join(",\n") + "\n"
|
|
78
|
+
+ " );\n"
|
|
79
|
+
+ "}";
|
|
80
|
+
}
|
|
81
|
+
function filter_parameters(route, query) {
|
|
82
|
+
var parameters = route.parameters.filter(function (param) { return param.category === "param"; });
|
|
83
|
+
if (query)
|
|
84
|
+
parameters.push(query);
|
|
85
|
+
return parameters;
|
|
86
|
+
}
|
|
87
|
+
/* ---------------------------------------------------------
|
|
88
|
+
HEAD & TAIL
|
|
89
|
+
--------------------------------------------------------- */
|
|
90
|
+
function head(route, query, input) {
|
|
91
|
+
//----
|
|
92
|
+
// CONSTRUCT COMMENT
|
|
93
|
+
//----
|
|
94
|
+
// MAIN DESCRIPTION
|
|
95
|
+
var comment = route.comments.map(function (comment) { return "".concat(comment.kind === "linkText" ? " " : "").concat(comment.text); }).join("");
|
|
96
|
+
if (comment !== "")
|
|
97
|
+
comment += "\n\n";
|
|
98
|
+
// FILTER TAGS (VULNERABLE PARAMETERS WOULD BE REMOVED)
|
|
99
|
+
var tagList = route.tags.filter(function (tag) { return tag.text !== undefined; });
|
|
100
|
+
if (tagList.length !== 0) {
|
|
101
|
+
var index = tagList.findIndex(function (t) { return t.name === "param"; });
|
|
102
|
+
if (index !== -1) {
|
|
103
|
+
var capsule = Vector_1.Vector.wrap(tagList);
|
|
104
|
+
capsule.insert(capsule.nth(index), {
|
|
105
|
+
name: "param",
|
|
106
|
+
text: [
|
|
107
|
+
{
|
|
108
|
+
kind: "parameterName",
|
|
109
|
+
text: "connection"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
kind: "space",
|
|
113
|
+
text: " "
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
kind: "text",
|
|
117
|
+
text: "connection Information of the remote HTTP(s) server with headers (+encryption password)"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
comment += tagList
|
|
123
|
+
.map(function (tag) { return "@".concat(tag.name, " ").concat(tag.text.map(function (elem) { return elem.text; }).join("")); })
|
|
124
|
+
.join("\n") + "\n\n";
|
|
125
|
+
}
|
|
126
|
+
// COMPLETE THE COMMENT
|
|
127
|
+
comment += "@nestia Generated by Nestia - https://github.com/samchon/nestia\n";
|
|
128
|
+
comment += "@controller ".concat(route.symbol, "\n");
|
|
129
|
+
comment += "@path ".concat(route.method, " ").concat(route.path);
|
|
130
|
+
//----
|
|
131
|
+
// FINALIZATION
|
|
132
|
+
//----
|
|
133
|
+
// REFORM PARAMETERS TEXT
|
|
134
|
+
var parameters = __spreadArray([
|
|
135
|
+
"connection: IConnection"
|
|
136
|
+
], __read(route.parameters.map(function (param) {
|
|
137
|
+
var type = (param === query || param === input)
|
|
138
|
+
? "Primitive<".concat(route.name, ".").concat(param === query ? "Query" : "Input", ">")
|
|
139
|
+
: param.type;
|
|
140
|
+
return "".concat(param.name, ": ").concat(type);
|
|
141
|
+
})), false);
|
|
142
|
+
// OUTPUT TYPE
|
|
143
|
+
var output = route.output === "void"
|
|
144
|
+
? "void"
|
|
145
|
+
: "".concat(route.name, ".Output");
|
|
146
|
+
// RETURNS WITH CONSTRUCTION
|
|
147
|
+
return ""
|
|
148
|
+
+ "/**\n"
|
|
149
|
+
+ comment.split("\r\n").join("\n").split("\n").map(function (str) { return " * ".concat(str); }).join("\n") + "\n"
|
|
150
|
+
+ " */\n"
|
|
151
|
+
+ "export function ".concat(route.name, "\n")
|
|
152
|
+
+ " (\n"
|
|
153
|
+
+ "".concat(parameters.map(function (str) { return " ".concat(str); }).join(",\n"), "\n")
|
|
154
|
+
+ " ): Promise<".concat(output, ">");
|
|
155
|
+
}
|
|
156
|
+
function tail(route, query, input) {
|
|
157
|
+
var e_1, _a;
|
|
158
|
+
// LIST UP TYPES
|
|
159
|
+
var types = [];
|
|
160
|
+
if (query !== undefined)
|
|
161
|
+
types.push(new Pair_1.Pair("Query", query.type));
|
|
162
|
+
if (input !== undefined)
|
|
163
|
+
types.push(new Pair_1.Pair("Input", input.type));
|
|
164
|
+
if (route.output !== "void")
|
|
165
|
+
types.push(new Pair_1.Pair("Output", route.output));
|
|
166
|
+
// PATH WITH PARAMETERS
|
|
167
|
+
var parameters = filter_parameters(route, query);
|
|
168
|
+
var path = route.path;
|
|
169
|
+
try {
|
|
170
|
+
for (var parameters_1 = __values(parameters), parameters_1_1 = parameters_1.next(); !parameters_1_1.done; parameters_1_1 = parameters_1.next()) {
|
|
171
|
+
var param = parameters_1_1.value;
|
|
172
|
+
if (param.category === "param")
|
|
173
|
+
path = path.replace(":".concat(param.field), "${".concat(param.name, "}"));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
177
|
+
finally {
|
|
178
|
+
try {
|
|
179
|
+
if (parameters_1_1 && !parameters_1_1.done && (_a = parameters_1.return)) _a.call(parameters_1);
|
|
180
|
+
}
|
|
181
|
+
finally { if (e_1) throw e_1.error; }
|
|
182
|
+
}
|
|
183
|
+
path = (query !== undefined)
|
|
184
|
+
? "`".concat(path, "?${new URLSearchParams(").concat(query.name, " as any).toString()}`")
|
|
185
|
+
: "`".concat(path, "`");
|
|
186
|
+
return "export namespace ".concat(route.name, "\n")
|
|
187
|
+
+ "{\n"
|
|
188
|
+
+
|
|
189
|
+
(types.length !== 0
|
|
190
|
+
? types.map(function (tuple) { return " export type ".concat(tuple.first, " = Primitive<").concat(tuple.second, ">;"); }).join("\n") + "\n"
|
|
191
|
+
: "")
|
|
192
|
+
+ "\n"
|
|
193
|
+
+ " export const METHOD = \"".concat(route.method, "\" as const;\n")
|
|
194
|
+
+ " export const PATH: string = \"".concat(route.path, "\";\n")
|
|
195
|
+
+ " export const ENCRYPTED: Fetcher.IEncrypted = {\n"
|
|
196
|
+
+ " request: ".concat(input !== undefined && input.encrypted, ",\n")
|
|
197
|
+
+ " response: ".concat(route.encrypted, ",\n")
|
|
198
|
+
+ " };\n"
|
|
199
|
+
+ "\n"
|
|
200
|
+
+ " export function path(".concat(parameters.map(function (param) { return "".concat(param.name, ": ").concat(param.type); }).join(", "), "): string\n")
|
|
201
|
+
+ " {\n"
|
|
202
|
+
+ " return ".concat(path, ";\n")
|
|
203
|
+
+ " }\n"
|
|
204
|
+
+ "}";
|
|
205
|
+
}
|
|
206
|
+
})(FunctionGenerator = exports.FunctionGenerator || (exports.FunctionGenerator = {}));
|
|
207
|
+
//# sourceMappingURL=FunctionGenerator.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IRoute } from "../structures/IRoute";
|
|
2
|
+
import { IConfiguration } from "../IConfiguration";
|
|
3
|
+
export declare namespace SdkGenerator {
|
|
4
|
+
function generate(config: IConfiguration, routeList: IRoute[]): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=SdkGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdkGenerator.d.ts","sourceRoot":"","sources":["../../src/generates/SdkGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,yBAAiB,YAAY,CAC7B;IACI,SAAsB,QAAQ,CAEtB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CAsBnB;CACJ"}
|
|
@@ -0,0 +1,147 @@
|
|
|
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.SdkGenerator = void 0;
|
|
74
|
+
var fs = __importStar(require("fs"));
|
|
75
|
+
var DirectoryUtil_1 = require("../utils/DirectoryUtil");
|
|
76
|
+
var FileGenerator_1 = require("./FileGenerator");
|
|
77
|
+
var SdkGenerator;
|
|
78
|
+
(function (SdkGenerator) {
|
|
79
|
+
function generate(config, routeList) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
var _a, bundle, bundle_1, bundle_1_1, file, current, stats, content, e_1_1;
|
|
82
|
+
var e_1, _b;
|
|
83
|
+
return __generator(this, function (_c) {
|
|
84
|
+
switch (_c.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
_c.trys.push([0, 2, , 3]);
|
|
87
|
+
return [4 /*yield*/, fs.promises.mkdir(config.output)];
|
|
88
|
+
case 1:
|
|
89
|
+
_c.sent();
|
|
90
|
+
return [3 /*break*/, 3];
|
|
91
|
+
case 2:
|
|
92
|
+
_a = _c.sent();
|
|
93
|
+
return [3 /*break*/, 3];
|
|
94
|
+
case 3: return [4 /*yield*/, fs.promises.readdir(BUNDLE)];
|
|
95
|
+
case 4:
|
|
96
|
+
bundle = _c.sent();
|
|
97
|
+
_c.label = 5;
|
|
98
|
+
case 5:
|
|
99
|
+
_c.trys.push([5, 12, 13, 14]);
|
|
100
|
+
bundle_1 = __values(bundle), bundle_1_1 = bundle_1.next();
|
|
101
|
+
_c.label = 6;
|
|
102
|
+
case 6:
|
|
103
|
+
if (!!bundle_1_1.done) return [3 /*break*/, 11];
|
|
104
|
+
file = bundle_1_1.value;
|
|
105
|
+
current = "".concat(BUNDLE, "/").concat(file);
|
|
106
|
+
return [4 /*yield*/, fs.promises.stat(current)];
|
|
107
|
+
case 7:
|
|
108
|
+
stats = _c.sent();
|
|
109
|
+
if (!(stats.isFile() === true)) return [3 /*break*/, 10];
|
|
110
|
+
return [4 /*yield*/, fs.promises.readFile(current, "utf8")];
|
|
111
|
+
case 8:
|
|
112
|
+
content = _c.sent();
|
|
113
|
+
return [4 /*yield*/, fs.promises.writeFile("".concat(config.output, "/").concat(file), content, "utf8")];
|
|
114
|
+
case 9:
|
|
115
|
+
_c.sent();
|
|
116
|
+
_c.label = 10;
|
|
117
|
+
case 10:
|
|
118
|
+
bundle_1_1 = bundle_1.next();
|
|
119
|
+
return [3 /*break*/, 6];
|
|
120
|
+
case 11: return [3 /*break*/, 14];
|
|
121
|
+
case 12:
|
|
122
|
+
e_1_1 = _c.sent();
|
|
123
|
+
e_1 = { error: e_1_1 };
|
|
124
|
+
return [3 /*break*/, 14];
|
|
125
|
+
case 13:
|
|
126
|
+
try {
|
|
127
|
+
if (bundle_1_1 && !bundle_1_1.done && (_b = bundle_1.return)) _b.call(bundle_1);
|
|
128
|
+
}
|
|
129
|
+
finally { if (e_1) throw e_1.error; }
|
|
130
|
+
return [7 /*endfinally*/];
|
|
131
|
+
case 14: return [4 /*yield*/, DirectoryUtil_1.DirectoryUtil.copy(BUNDLE + "/__internal", config.output + "/__internal")];
|
|
132
|
+
case 15:
|
|
133
|
+
_c.sent();
|
|
134
|
+
// FUNCTIONAL
|
|
135
|
+
return [4 /*yield*/, FileGenerator_1.FileGenerator.generate(config, routeList)];
|
|
136
|
+
case 16:
|
|
137
|
+
// FUNCTIONAL
|
|
138
|
+
_c.sent();
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
SdkGenerator.generate = generate;
|
|
145
|
+
})(SdkGenerator = exports.SdkGenerator || (exports.SdkGenerator = {}));
|
|
146
|
+
var BUNDLE = __dirname + "/../bundle";
|
|
147
|
+
//# sourceMappingURL=SdkGenerator.js.map
|
package/bin/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,eAAe,MAAM,CAAC"}
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
var nestia = __importStar(require("./module"));
|
|
27
|
+
exports.default = nestia;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/bin/module.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
package/bin/module.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IConfiguration"), exports);
|
|
18
|
+
__exportStar(require("./NestiaApplication"), exports);
|
|
19
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
import { ParamCategory } from "./ParamCategory";
|
|
2
|
-
|
|
3
|
-
export interface IController
|
|
4
|
-
{
|
|
2
|
+
export interface IController {
|
|
5
3
|
file: string;
|
|
6
4
|
name: string;
|
|
7
5
|
path: string;
|
|
8
6
|
functions: IController.IFunction[];
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
export interface IFunction
|
|
14
|
-
{
|
|
8
|
+
export declare namespace IController {
|
|
9
|
+
interface IFunction {
|
|
15
10
|
name: string;
|
|
16
11
|
method: string;
|
|
17
12
|
path: string;
|
|
18
13
|
encrypted: boolean;
|
|
19
|
-
|
|
20
14
|
parameters: IParameter[];
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
export interface IParameter
|
|
24
|
-
{
|
|
16
|
+
interface IParameter {
|
|
25
17
|
name: string;
|
|
26
18
|
index: number;
|
|
27
19
|
field: string | undefined;
|
|
28
20
|
category: ParamCategory;
|
|
29
21
|
encrypted: boolean;
|
|
30
22
|
}
|
|
31
|
-
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=IController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IController.d.ts","sourceRoot":"","sources":["../../src/structures/IController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,WAAW;IAExB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,WAAW,CAAC,SAAS,EAAE,CAAC;CACtC;AAED,yBAAiB,WAAW,CAC5B;IACI,UAAiB,SAAS;QAEtB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,OAAO,CAAC;QAEnB,UAAU,EAAE,UAAU,EAAE,CAAC;KAC5B;IAED,UAAiB,UAAU;QAEvB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,QAAQ,EAAE,aAAa,CAAC;QACxB,SAAS,EAAE,OAAO,CAAC;KACtB;CACJ"}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import * as tsc from "typescript";
|
|
2
2
|
import { ParamCategory } from "./ParamCategory";
|
|
3
|
-
|
|
4
|
-
export interface IRoute
|
|
5
|
-
{
|
|
3
|
+
export interface IRoute {
|
|
6
4
|
name: string;
|
|
7
5
|
method: string;
|
|
8
6
|
path: string;
|
|
9
7
|
encrypted: boolean;
|
|
10
|
-
|
|
11
8
|
parameters: IRoute.IParameter[];
|
|
12
9
|
imports: [string, string[]][];
|
|
13
10
|
output: string;
|
|
14
|
-
|
|
15
11
|
symbol: string;
|
|
16
12
|
comments: tsc.SymbolDisplayPart[];
|
|
17
13
|
tags: tsc.JSDocTagInfo[];
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
export interface IParameter
|
|
23
|
-
{
|
|
15
|
+
export declare namespace IRoute {
|
|
16
|
+
interface IParameter {
|
|
24
17
|
name: string;
|
|
25
18
|
field: string | undefined;
|
|
26
19
|
category: ParamCategory;
|
|
27
20
|
encrypted: boolean;
|
|
28
21
|
type: string;
|
|
29
22
|
}
|
|
30
|
-
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=IRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRoute.d.ts","sourceRoot":"","sources":["../../src/structures/IRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,MAAM;IAEnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IAEnB,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;IAChC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAClC,IAAI,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;CAC5B;AAED,yBAAiB,MAAM,CACvB;IACI,UAAiB,UAAU;QAEvB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,QAAQ,EAAE,aAAa,CAAC;QACxB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KAChB;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodType.d.ts","sourceRoot":"","sources":["../../src/structures/MethodType.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,yBAAiB,UAAU,CAC3B;IACW,MAAM,MAAM,EAAE,UAAU,EAA8C,CAAC;CACjF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MethodType = void 0;
|
|
4
|
+
var MethodType;
|
|
5
|
+
(function (MethodType) {
|
|
6
|
+
MethodType.VALUES = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
7
|
+
})(MethodType = exports.MethodType || (exports.MethodType = {}));
|
|
8
|
+
//# sourceMappingURL=MethodType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParamCategory.d.ts","sourceRoot":"","sources":["../../src/structures/ParamCategory.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare namespace ArrayUtil {
|
|
2
|
+
function has<T>(array: T[], ...items: T[]): boolean;
|
|
3
|
+
function asyncMap<Input, Output>(array: Input[], closure: (input: Input) => Promise<Output>): Promise<Output[]>;
|
|
4
|
+
function asyncFilter<Input>(array: Input[], closure: (input: Input) => Promise<boolean>): Promise<Input[]>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ArrayUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayUtil.d.ts","sourceRoot":"","sources":["../../src/utils/ArrayUtil.ts"],"names":[],"mappings":"AAAA,yBAAiB,SAAS,CAC1B;IACI,SAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,OAAO,CAGzD;IAED,SAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,EACvC,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAMlF;IAED,SAAsB,WAAW,CAAC,KAAK,EAClC,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAOlF;CACJ"}
|