nestia 2.0.13-dev.20220421 → 2.0.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ControllerAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAK9C,yBAAiB,kBAAkB,CACnC;IACI,SAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,CAc/G;CA+HJ"}
1
+ {"version":3,"file":"ControllerAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAK9C,yBAAiB,kBAAkB,CACnC;IACI,SAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,CAc/G;CAyIJ"}
@@ -156,13 +156,18 @@ var ControllerAnalyzer;
156
156
  var output = ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, checker.getReturnTypeOfSignature(signature));
157
157
  var imports = importDict.toJSON().map(function (pair) { return [pair.first, pair.second.toJSON()]; });
158
158
  // CONFIGURE PATH
159
- var path = NodePath.join(controller.path, func.path).split("\\").join("/");
159
+ var path = _Normalize_path(NodePath.join(controller.path, func.path)
160
+ .split("\\")
161
+ .join("/"));
162
+ // RETURNS
163
+ return __assign(__assign({}, func), { path: path, parameters: parameters, output: output, imports: imports, symbol: "".concat(controller.name, ".").concat(func.name, "()"), comments: signature.getDocumentationComment(undefined), tags: signature.getJsDocTags() });
164
+ }
165
+ function _Normalize_path(path) {
160
166
  if (path[0] !== "/")
161
167
  path = "/" + path;
162
168
  if (path[path.length - 1] === "/" && path !== "/")
163
169
  path = path.substr(0, path.length - 1);
164
- // RETURNS
165
- return __assign(__assign({}, func), { path: path, parameters: parameters, output: output, imports: imports, symbol: "".concat(controller.name, ".").concat(func.name, "()"), comments: signature.getDocumentationComment(undefined), tags: signature.getJsDocTags() });
170
+ return path;
166
171
  }
167
172
  /* ---------------------------------------------------------
168
173
  PARAMETER
@@ -1,4 +1,4 @@
1
- import * as tsc from "typescript";
1
+ import tsc from "typescript";
2
2
  import { HashMap } from "tstl/container/HashMap";
3
3
  import { HashSet } from "tstl/container/HashSet";
4
4
  import { GenericAnalyzer } from "./GenericAnalyzer";
@@ -1 +1 @@
1
- {"version":3,"file":"ImportAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ImportAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,yBAAiB,cAAc,CAC/B;IACI,UAAiB,OAAO;QAEpB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC/B,KAAK,EAAE,MAAM,CAAC;KACjB;IAED,KAAY,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,SAAgB,OAAO,CAEf,OAAO,EAAE,GAAG,CAAC,WAAW,EACxB,WAAW,EAAE,eAAe,CAAC,UAAU,EACvC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,GAAG,CAAC,IAAI,GACf,MAAM,CAGZ;CAmEJ"}
1
+ {"version":3,"file":"ImportAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ImportAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,yBAAiB,cAAc,CAC/B;IACI,UAAiB,OAAO;QAEpB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC/B,KAAK,EAAE,MAAM,CAAC;KACjB;IAED,KAAY,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,SAAgB,OAAO,CAEf,OAAO,EAAE,GAAG,CAAC,WAAW,EACxB,WAAW,EAAE,eAAe,CAAC,UAAU,EACvC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,GAAG,CAAC,IAAI,GACf,MAAM,CAGZ;CAsEJ"}
@@ -1,30 +1,10 @@
1
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;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
6
  exports.ImportAnalyzer = void 0;
27
- var tsc = __importStar(require("typescript"));
7
+ var typescript_1 = __importDefault(require("typescript"));
28
8
  var HashSet_1 = require("tstl/container/HashSet");
29
9
  var ImportAnalyzer;
30
10
  (function (ImportAnalyzer) {
@@ -54,29 +34,25 @@ var ImportAnalyzer;
54
34
  var name = get_name(symbol);
55
35
  var sourceFile = symbol.declarations[0].getSourceFile();
56
36
  if (sourceFile.fileName.indexOf("typescript/lib") === -1) {
57
- var it = importDict.find(sourceFile.fileName);
58
- if (it.equals(importDict.end()) === true)
59
- it = importDict.emplace(sourceFile.fileName, new HashSet_1.HashSet()).first;
60
- it.second.insert(name.split(".")[0]);
37
+ var set = importDict.take(sourceFile.fileName, function () { return new HashSet_1.HashSet(); });
38
+ set.insert(name.split(".")[0]);
61
39
  }
62
40
  // CHECK GENERIC
63
41
  var generic = checker.getTypeArguments(type);
64
- if (generic.length) {
42
+ if (generic.length)
65
43
  return name === "Promise"
66
44
  ? explore(checker, genericDict, importDict, generic[0])
67
45
  : "".concat(name, "<").concat(generic.map(function (child) { return explore(checker, genericDict, importDict, child); }).join(", "), ">");
68
- }
69
46
  else
70
47
  return name;
71
48
  }
72
49
  function get_name(symbol) {
73
- var name = symbol.escapedName.toString();
74
- var decl = symbol.getDeclarations()[0].parent;
75
- while (tsc.isModuleBlock(decl)) {
76
- name = "".concat(decl.parent.name.getText(), ".").concat(name);
77
- decl = decl.parent.parent;
78
- }
79
- return name;
50
+ return explore_name(symbol.escapedName.toString(), symbol.getDeclarations()[0].parent);
51
+ }
52
+ function explore_name(name, decl) {
53
+ return typescript_1.default.isModuleBlock(decl)
54
+ ? explore_name("".concat(decl.parent.name.getText(), ".").concat(name), decl.parent.parent)
55
+ : name;
80
56
  }
81
57
  })(ImportAnalyzer = exports.ImportAnalyzer || (exports.ImportAnalyzer = {}));
82
58
  //# sourceMappingURL=ImportAnalyzer.js.map
@@ -83,13 +83,13 @@ var CompilerOptions;
83
83
  // INITALIZE PLUGINS
84
84
  if (!options.plugins || !(options.plugins instanceof Array))
85
85
  options.plugins = [];
86
- var transformed = false;
86
+ var transformed = [];
87
87
  var plugins = options.plugins;
88
88
  var emplace = function (input) {
89
89
  var found = plugins.find(function (p) { return nestia_fetcher_1.Primitive.equal_to(p, input); });
90
90
  if (found === undefined)
91
91
  plugins.push(input);
92
- transformed || (transformed = true);
92
+ transformed.push(true);
93
93
  };
94
94
  if (assert === true)
95
95
  emplace({
@@ -97,7 +97,7 @@ var CompilerOptions;
97
97
  });
98
98
  if (options.paths && Object.entries(options.paths).length !== 0)
99
99
  emplace({ transform: "typescript-transform-paths" });
100
- return [transformed, !!options.baseUrl];
100
+ return [!!transformed.length, !!options.baseUrl];
101
101
  }
102
102
  CompilerOptions.emend = emend;
103
103
  function merge_array(origin, must) {
@@ -1 +1 @@
1
- {"version":3,"file":"NestiaSdkCli.d.ts","sourceRoot":"","sources":["../../../src/executable/internal/NestiaSdkCli.ts"],"names":[],"mappings":"AAiBA,yBAAiB,YAAY,CAC7B;IACI,SAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBlF;CAwDJ"}
1
+ {"version":3,"file":"NestiaSdkCli.d.ts","sourceRoot":"","sources":["../../../src/executable/internal/NestiaSdkCli.ts"],"names":[],"mappings":"AAiBA,yBAAiB,YAAY,CAC7B;IACI,SAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBlF;CA2DJ"}
@@ -162,44 +162,32 @@ var NestiaSdkCli;
162
162
  }
163
163
  NestiaSdkCli.main = main;
164
164
  function generate(include, command) {
165
+ var _a;
165
166
  return __awaiter(this, void 0, void 0, function () {
166
167
  var config, parentPath, parentStats, content, options, app;
167
- return __generator(this, function (_a) {
168
- switch (_a.label) {
168
+ return __generator(this, function (_b) {
169
+ switch (_b.label) {
169
170
  case 0: return [4 /*yield*/, get_nestia_config()];
170
171
  case 1:
171
- config = _a.sent();
172
- if (config === null) {
173
- if (command.out === null)
174
- throw new Error("Output directory is not specified. Add the \"--out <output_directory>\" option.");
175
- config = {
176
- input: {
177
- include: include,
178
- exclude: command.exclude
179
- ? [command.exclude]
180
- : undefined
181
- },
182
- output: command.out
183
- };
184
- }
172
+ config = (_a = _b.sent()) !== null && _a !== void 0 ? _a : parse_cli(include, command);
185
173
  parentPath = path.resolve(config.output + "/..");
186
174
  return [4 /*yield*/, fs.promises.stat(parentPath)];
187
175
  case 2:
188
- parentStats = _a.sent();
176
+ parentStats = _b.sent();
189
177
  if (parentStats.isDirectory() === false)
190
178
  throw new Error("Unable to find parent directory of the output path: \"".concat(parentPath, "\"."));
191
179
  if (!(fs.existsSync("tsconfig.json") === true)) return [3 /*break*/, 4];
192
180
  return [4 /*yield*/, fs.promises.readFile("tsconfig.json", "utf8")];
193
181
  case 3:
194
- content = _a.sent();
182
+ content = _b.sent();
195
183
  options = jsonc_simple_parser_1.default.parse(content).compilerOptions;
196
184
  config.compilerOptions = __assign(__assign({}, options), (config.compilerOptions || {}));
197
- _a.label = 4;
185
+ _b.label = 4;
198
186
  case 4:
199
187
  app = new NestiaApplication_1.NestiaApplication(config);
200
188
  return [4 /*yield*/, app.generate()];
201
189
  case 5:
202
- _a.sent();
190
+ _b.sent();
203
191
  return [2 /*return*/];
204
192
  }
205
193
  });
@@ -229,5 +217,18 @@ var NestiaSdkCli;
229
217
  });
230
218
  });
231
219
  }
220
+ function parse_cli(include, command) {
221
+ if (command.out === null)
222
+ throw new Error("Output directory is not specified. Add the \"--out <output_directory>\" option.");
223
+ return {
224
+ input: {
225
+ include: include,
226
+ exclude: command.exclude
227
+ ? [command.exclude]
228
+ : undefined
229
+ },
230
+ output: command.out
231
+ };
232
+ }
232
233
  })(NestiaSdkCli = exports.NestiaSdkCli || (exports.NestiaSdkCli = {}));
233
234
  //# sourceMappingURL=NestiaSdkCli.js.map
@@ -78,7 +78,7 @@ function install() {
78
78
  var e_1, _a;
79
79
  try {
80
80
  // INSTALL DEPENDENCIES
81
- for (var _b = __values(["nestia-fetcher", "typescript-is"]), _c = _b.next(); !_c.done; _c = _b.next()) {
81
+ for (var _b = __values(["nestia-fetcher", "typescript-is", "typescript-json"]), _c = _b.next(); !_c.done; _c = _b.next()) {
82
82
  var lib = _c.value;
83
83
  var command = "npm install ".concat(lib);
84
84
  cp.execSync(command, { stdio: "inherit" });
@@ -1 +1 @@
1
- {"version":3,"file":"FileGenerator.d.ts","sourceRoot":"","sources":["../../src/generates/FileGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,yBAAiB,aAAa,CAC9B;IAII,SAAsB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAYzF;CA+GJ"}
1
+ {"version":3,"file":"FileGenerator.d.ts","sourceRoot":"","sources":["../../src/generates/FileGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,yBAAiB,aAAa,CAC9B;IAII,SAAsB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAYzF;CAwHJ"}
@@ -69,6 +69,31 @@ var __values = (this && this.__values) || function(o) {
69
69
  };
70
70
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
71
71
  };
72
+ var __read = (this && this.__read) || function (o, n) {
73
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
74
+ if (!m) return o;
75
+ var i = m.call(o), r, ar = [], e;
76
+ try {
77
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
78
+ }
79
+ catch (error) { e = { error: error }; }
80
+ finally {
81
+ try {
82
+ if (r && !r.done && (m = i["return"])) m.call(i);
83
+ }
84
+ finally { if (e) throw e.error; }
85
+ }
86
+ return ar;
87
+ };
88
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
89
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
90
+ if (ar || !(i in from)) {
91
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
92
+ ar[i] = from[i];
93
+ }
94
+ }
95
+ return to.concat(ar || Array.prototype.slice.call(from));
96
+ };
72
97
  Object.defineProperty(exports, "__esModule", { value: true });
73
98
  exports.FileGenerator = void 0;
74
99
  var fs = __importStar(require("fs"));
@@ -121,15 +146,14 @@ var FileGenerator;
121
146
  .split("/")
122
147
  .filter(function (str) { return str[0] !== ":" && str.length !== 0; })
123
148
  .map(function (str) { return str.split("-").join("_").split(".").join("_"); });
149
+ var _loop_1 = function (key) {
150
+ directory = directory.directories.take(key, function () { return new Directory(directory, key); });
151
+ };
124
152
  try {
153
+ // OPEN DIRECTORIES
125
154
  for (var identifiers_1 = __values(identifiers), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
126
155
  var key = identifiers_1_1.value;
127
- // EMPLACE IF REQUIRED
128
- var it = directory.directories.find(key);
129
- if (it.equals(directory.directories.end()) === true)
130
- it = directory.directories.emplace(key, new Directory(directory, key)).first;
131
- // FOR THE NEXT STEP
132
- directory = it.second;
156
+ _loop_1(key);
133
157
  }
134
158
  }
135
159
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -139,6 +163,7 @@ var FileGenerator;
139
163
  }
140
164
  finally { if (e_2) throw e_2.error; }
141
165
  }
166
+ // ADD ROUTE
142
167
  directory.routes.push(route);
143
168
  }
144
169
  function relocate(directory) {
@@ -170,89 +195,83 @@ var FileGenerator;
170
195
  --------------------------------------------------------- */
171
196
  function iterate(config, outDir, directory) {
172
197
  return __awaiter(this, void 0, void 0, function () {
173
- var _a, content, _b, _c, it, e_4_1, importDict, _d, _e, route, _f, _g, tuple, _h, _j, instance, primitived, asserted, json, fetcher;
174
- var e_4, _k, e_5, _l, e_6, _m, e_7, _o;
175
- return __generator(this, function (_p) {
176
- switch (_p.label) {
198
+ var _a, content, _b, _c, it, e_4_1, importDict, primitived, asserted, json, fetcher, head, script;
199
+ var e_4, _d;
200
+ return __generator(this, function (_e) {
201
+ switch (_e.label) {
177
202
  case 0:
178
- _p.trys.push([0, 2, , 3]);
203
+ _e.trys.push([0, 2, , 3]);
179
204
  return [4 /*yield*/, fs.promises.mkdir(outDir)];
180
205
  case 1:
181
- _p.sent();
206
+ _e.sent();
182
207
  return [3 /*break*/, 3];
183
208
  case 2:
184
- _a = _p.sent();
209
+ _a = _e.sent();
185
210
  return [3 /*break*/, 3];
186
211
  case 3:
187
- content = "";
188
- _p.label = 4;
212
+ content = [];
213
+ _e.label = 4;
189
214
  case 4:
190
- _p.trys.push([4, 9, 10, 11]);
215
+ _e.trys.push([4, 9, 10, 11]);
191
216
  _b = __values(directory.directories), _c = _b.next();
192
- _p.label = 5;
217
+ _e.label = 5;
193
218
  case 5:
194
219
  if (!!_c.done) return [3 /*break*/, 8];
195
220
  it = _c.value;
196
221
  return [4 /*yield*/, iterate(config, "".concat(outDir, "/").concat(it.first), it.second)];
197
222
  case 6:
198
- _p.sent();
199
- content += "export * as ".concat(it.first, " from \"./").concat(it.first, "\";\n");
200
- _p.label = 7;
223
+ _e.sent();
224
+ content.push("export * as ".concat(it.first, " from \"./").concat(it.first, "\";"));
225
+ _e.label = 7;
201
226
  case 7:
202
227
  _c = _b.next();
203
228
  return [3 /*break*/, 5];
204
229
  case 8: return [3 /*break*/, 11];
205
230
  case 9:
206
- e_4_1 = _p.sent();
231
+ e_4_1 = _e.sent();
207
232
  e_4 = { error: e_4_1 };
208
233
  return [3 /*break*/, 11];
209
234
  case 10:
210
235
  try {
211
- if (_c && !_c.done && (_k = _b.return)) _k.call(_b);
236
+ if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
212
237
  }
213
238
  finally { if (e_4) throw e_4.error; }
214
239
  return [7 /*endfinally*/];
215
240
  case 11:
216
- content += "\n";
241
+ if (content.length && directory.routes.length)
242
+ content.push("");
217
243
  importDict = new ImportDictionary_1.ImportDictionary();
218
- try {
219
- for (_d = __values(directory.routes), _e = _d.next(); !_e.done; _e = _d.next()) {
220
- route = _e.value;
221
- try {
222
- for (_f = (e_6 = void 0, __values(route.imports)), _g = _f.next(); !_g.done; _g = _f.next()) {
223
- tuple = _g.value;
224
- try {
225
- for (_h = (e_7 = void 0, __values(tuple[1])), _j = _h.next(); !_j.done; _j = _h.next()) {
226
- instance = _j.value;
227
- importDict.emplace(tuple[0], false, instance);
228
- }
229
- }
230
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
231
- finally {
232
- try {
233
- if (_j && !_j.done && (_o = _h.return)) _o.call(_h);
234
- }
235
- finally { if (e_7) throw e_7.error; }
244
+ directory.routes.forEach(function (route, i) {
245
+ var e_5, _a, e_6, _b;
246
+ try {
247
+ for (var _c = __values(route.imports), _d = _c.next(); !_d.done; _d = _c.next()) {
248
+ var tuple = _d.value;
249
+ try {
250
+ for (var _e = (e_6 = void 0, __values(tuple[1])), _f = _e.next(); !_f.done; _f = _e.next()) {
251
+ var instance = _f.value;
252
+ importDict.emplace(tuple[0], false, instance);
236
253
  }
237
254
  }
238
- }
239
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
240
- finally {
241
- try {
242
- if (_g && !_g.done && (_m = _f.return)) _m.call(_f);
255
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
256
+ finally {
257
+ try {
258
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
259
+ }
260
+ finally { if (e_6) throw e_6.error; }
243
261
  }
244
- finally { if (e_6) throw e_6.error; }
245
262
  }
246
- content += FunctionGenerator_1.FunctionGenerator.generate(config, route) + "\n\n";
247
263
  }
248
- }
249
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
250
- finally {
251
- try {
252
- if (_e && !_e.done && (_l = _d.return)) _l.call(_d);
264
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
265
+ finally {
266
+ try {
267
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
268
+ }
269
+ finally { if (e_5) throw e_5.error; }
253
270
  }
254
- finally { if (e_5) throw e_5.error; }
255
- }
271
+ content.push(FunctionGenerator_1.FunctionGenerator.generate(config, route));
272
+ if (i !== directory.routes.length - 1)
273
+ content.push("");
274
+ });
256
275
  // FINALIZE THE CONTENT
257
276
  if (directory.routes.length !== 0) {
258
277
  primitived = directory.routes.some(function (route) { return route.output !== "void"
@@ -264,26 +283,27 @@ var FileGenerator;
264
283
  fetcher = ["Fetcher"];
265
284
  if (primitived)
266
285
  fetcher.push("Primitive");
267
- content = ""
268
- + "import { ".concat(fetcher.join(", "), " } from \"nestia-fetcher\";\n")
269
- + "import type { IConnection } from \"nestia-fetcher\";\n"
270
- + (asserted ? "import { assertType } from \"typescript-is\";\n" : "")
271
- + (json ? "import { createStringifier } from \"typescript-json\";\n" : "")
272
- +
273
- (importDict.empty()
274
- ? ""
275
- : "\n" + importDict.toScript(outDir) + "\n")
276
- + content;
286
+ head = [
287
+ "import { ".concat(fetcher.join(", "), " } from \"nestia-fetcher\";"),
288
+ "import type { IConnection } from \"nestia-fetcher\";",
289
+ ];
290
+ if (asserted)
291
+ head.push("import { assertType } from \"typescript-is\";");
292
+ if (json)
293
+ head.push("import { createStringifier } from \"typescript-json\";");
294
+ if (!importDict.empty())
295
+ head.push("", importDict.toScript(outDir));
296
+ content.push.apply(content, __spreadArray(__spreadArray(__spreadArray([], __read(head), false), [""], false), __read(content.splice(0, content.length)), false));
277
297
  }
278
- content = "/**\n"
298
+ script = "/**\n"
279
299
  + " * @packageDocumentation\n"
280
300
  + " * @module ".concat(directory.module, "\n")
281
301
  + " */\n"
282
302
  + "//================================================================\n"
283
- + content;
284
- return [4 /*yield*/, fs.promises.writeFile("".concat(outDir, "/index.ts"), content, "utf8")];
303
+ + content.join("\n");
304
+ return [4 /*yield*/, fs.promises.writeFile("".concat(outDir, "/index.ts"), script, "utf8")];
285
305
  case 12:
286
- _p.sent();
306
+ _e.sent();
287
307
  return [2 /*return*/];
288
308
  }
289
309
  });
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionGenerator.d.ts","sourceRoot":"","sources":["../../src/generates/FunctionGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,yBAAiB,iBAAiB,CAClC;IACI,SAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAStE;CAkMJ"}
1
+ {"version":3,"file":"FunctionGenerator.d.ts","sourceRoot":"","sources":["../../src/generates/FunctionGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,yBAAiB,iBAAiB,CAClC;IACI,SAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAStE;CAqNJ"}
@@ -95,9 +95,14 @@ var FunctionGenerator;
95
95
  // CONSTRUCT COMMENT
96
96
  //----
97
97
  // MAIN DESCRIPTION
98
- var comment = route.comments.map(function (comment) { return "".concat(comment.kind === "linkText" ? " " : "").concat(comment.text); }).join("");
99
- if (comment !== "")
100
- comment += "\n\n";
98
+ var comment = route.comments
99
+ .map(function (part) { return "".concat(part.kind === "linkText" ? " " : "").concat(part.text); })
100
+ .map(function (str) { return str.split("\r\n").join("\n"); })
101
+ .join("")
102
+ .split("\n")
103
+ .filter(function (str, i, array) { return str !== "" || i !== array.length - 1; });
104
+ if (comment.length)
105
+ comment.push("");
101
106
  // FILTER TAGS (VULNERABLE PARAMETERS WOULD BE REMOVED)
102
107
  var tagList = route.tags.filter(function (tag) { return tag.text !== undefined; });
103
108
  if (tagList.length !== 0) {
@@ -122,14 +127,10 @@ var FunctionGenerator;
122
127
  ]
123
128
  });
124
129
  }
125
- comment += tagList
126
- .map(function (tag) { return "@".concat(tag.name, " ").concat(tag.text.map(function (elem) { return elem.text; }).join("")); })
127
- .join("\n") + "\n\n";
130
+ comment.push.apply(comment, __spreadArray(__spreadArray([], __read(tagList.map(function (tag) { return "@".concat(tag.name, " ").concat(tag.text.map(function (elem) { return elem.text; }).join("")); })), false), [""], false));
128
131
  }
129
132
  // COMPLETE THE COMMENT
130
- comment += "@nestia Generated by Nestia - https://github.com/samchon/nestia\n";
131
- comment += "@controller ".concat(route.symbol, "\n");
132
- comment += "@path ".concat(route.method, " ").concat(route.path);
133
+ comment.push("@nestia Generated by Nestia - https://github.com/samchon/nestia", "@controller ".concat(route.symbol), "@path ".concat(route.method, " ").concat(route.path));
133
134
  //----
134
135
  // FINALIZATION
135
136
  //----
@@ -149,7 +150,7 @@ var FunctionGenerator;
149
150
  // RETURNS WITH CONSTRUCTION
150
151
  return ""
151
152
  + "/**\n"
152
- + comment.split("\r\n").join("\n").split("\n").map(function (str) { return " * ".concat(str); }).join("\n") + "\n"
153
+ + comment.map(function (str) { return " * ".concat(str); }).join("\n") + "\n"
153
154
  + " */\n"
154
155
  + "export function ".concat(route.name, "\n")
155
156
  + " (\n"
@@ -157,7 +158,6 @@ var FunctionGenerator;
157
158
  + " ): Promise<".concat(output, ">");
158
159
  }
159
160
  function tail(route, query, input, config) {
160
- var e_1, _a;
161
161
  // LIST UP TYPES
162
162
  var types = [];
163
163
  if (query !== undefined)
@@ -168,24 +168,7 @@ var FunctionGenerator;
168
168
  types.push(new Pair_1.Pair("Output", route.output));
169
169
  // PATH WITH PARAMETERS
170
170
  var parameters = filter_parameters(route, query);
171
- var path = route.path;
172
- try {
173
- for (var parameters_1 = __values(parameters), parameters_1_1 = parameters_1.next(); !parameters_1_1.done; parameters_1_1 = parameters_1.next()) {
174
- var param = parameters_1_1.value;
175
- if (param.category === "param")
176
- path = path.replace(":".concat(param.field), "${".concat(param.name, "}"));
177
- }
178
- }
179
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
180
- finally {
181
- try {
182
- if (parameters_1_1 && !parameters_1_1.done && (_a = parameters_1.return)) _a.call(parameters_1);
183
- }
184
- finally { if (e_1) throw e_1.error; }
185
- }
186
- path = (query !== undefined)
187
- ? "`".concat(path, "?${new URLSearchParams(").concat(query.name, " as any).toString()}`")
188
- : "`".concat(path, "`");
171
+ var path = compute_path(query, parameters, route.path);
189
172
  return "export namespace ".concat(route.name, "\n")
190
173
  + "{\n"
191
174
  +
@@ -210,5 +193,25 @@ var FunctionGenerator;
210
193
  : "")
211
194
  + "}";
212
195
  }
196
+ function compute_path(query, parameters, path) {
197
+ var e_1, _a;
198
+ try {
199
+ for (var parameters_1 = __values(parameters), parameters_1_1 = parameters_1.next(); !parameters_1_1.done; parameters_1_1 = parameters_1.next()) {
200
+ var param = parameters_1_1.value;
201
+ if (param.category === "param")
202
+ path = path.replace(":".concat(param.field), "${".concat(param.name, "}"));
203
+ }
204
+ }
205
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
206
+ finally {
207
+ try {
208
+ if (parameters_1_1 && !parameters_1_1.done && (_a = parameters_1.return)) _a.call(parameters_1);
209
+ }
210
+ finally { if (e_1) throw e_1.error; }
211
+ }
212
+ return (query !== undefined)
213
+ ? "`".concat(path, "?${new URLSearchParams(").concat(query.name, " as any).toString()}`")
214
+ : "`".concat(path, "`");
215
+ }
213
216
  })(FunctionGenerator = exports.FunctionGenerator || (exports.FunctionGenerator = {}));
214
217
  //# sourceMappingURL=FunctionGenerator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImportDictionary.d.ts","sourceRoot":"","sources":["../../src/utils/ImportDictionary.ts"],"names":[],"mappings":"AAMA,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkE;IAEjF,KAAK,IAAI,OAAO;IAKhB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAejE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAa1C"}
1
+ {"version":3,"file":"ImportDictionary.d.ts","sourceRoot":"","sources":["../../src/utils/ImportDictionary.ts"],"names":[],"mappings":"AAMA,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkE;IAEjF,KAAK,IAAI,OAAO;IAKhB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAiBjE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAa1C"}
@@ -53,10 +53,8 @@ var ImportDictionary = /** @class */ (function () {
53
53
  file = file.substr(0, file.length - 3);
54
54
  else
55
55
  throw new Error("Error on ImportDictionary.emplace(): extension of the target file \"".concat(file, "\" is not \"ts\"."));
56
- var it = this.dict_.find(file);
57
- if (it.equals(this.dict_.end()) === true)
58
- it = this.dict_.emplace(file, new Pair_1.Pair(realistic, new HashSet_1.HashSet())).first;
59
- it.second.second.insert(instance);
56
+ var pair = this.dict_.take(file, function () { return new Pair_1.Pair(realistic, new HashSet_1.HashSet()); });
57
+ pair.second.insert(instance);
60
58
  };
61
59
  ImportDictionary.prototype.toScript = function (outDir) {
62
60
  var e_1, _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestia",
3
- "version": "2.0.13-dev.20220421",
3
+ "version": "2.0.15",
4
4
  "description": "Automatic SDK and Document generator for the NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -36,13 +36,13 @@
36
36
  "jsonc-simple-parser": "^2.2.1",
37
37
  "nestia-fetcher": "^2.0.1",
38
38
  "tgrid": "^0.8.6",
39
- "ts-node": "^10.4.0",
39
+ "ts-node": "^10.7.0",
40
40
  "tsconfig-paths": "^3.14.1",
41
- "tstl": "^2.5.3",
41
+ "tstl": "^2.5.5",
42
42
  "ttypescript": "^1.5.13",
43
43
  "typescript": "^4.6.3",
44
44
  "typescript-is": "^0.19.0",
45
- "typescript-json": "^2.0.2",
45
+ "typescript-json": "^2.0.4",
46
46
  "typescript-transform-paths": "^3.3.1"
47
47
  },
48
48
  "devDependencies": {
@@ -1,4 +0,0 @@
1
- export declare function stripJsonComments(jsonString: string, { whitespace }?: {
2
- whitespace?: boolean | undefined;
3
- }): string;
4
- //# sourceMappingURL=stripJsonComments.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stripJsonComments.d.ts","sourceRoot":"","sources":["../../src/utils/stripJsonComments.ts"],"names":[],"mappings":"AAoBA,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAC,UAAiB,EAAC;;CAAK,UA0D7E"}
@@ -1,76 +0,0 @@
1
- "use strict";
2
- // https://github.com/sindresorhus/strip-json-comments
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.stripJsonComments = void 0;
5
- var singleComment = Symbol('singleComment');
6
- var multiComment = Symbol('multiComment');
7
- var stripWithoutWhitespace = function () { return ''; };
8
- var stripWithWhitespace = function (string, start, end) { return string.slice(start, end).replace(/\S/g, ' '); };
9
- var isEscaped = function (jsonString, quotePosition) {
10
- var index = quotePosition - 1;
11
- var backslashCount = 0;
12
- while (jsonString[index] === '\\') {
13
- index -= 1;
14
- backslashCount += 1;
15
- }
16
- return Boolean(backslashCount % 2);
17
- };
18
- function stripJsonComments(jsonString, _a) {
19
- var _b = _a === void 0 ? {} : _a, _c = _b.whitespace, whitespace = _c === void 0 ? true : _c;
20
- if (typeof jsonString !== 'string') {
21
- throw new TypeError("Expected argument `jsonString` to be a `string`, got `".concat(typeof jsonString, "`"));
22
- }
23
- var strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
24
- var isInsideString = false;
25
- var isInsideComment = false;
26
- var offset = 0;
27
- var result = '';
28
- for (var index = 0; index < jsonString.length; index++) {
29
- var currentCharacter = jsonString[index];
30
- var nextCharacter = jsonString[index + 1];
31
- if (!isInsideComment && currentCharacter === '"') {
32
- var escaped = isEscaped(jsonString, index);
33
- if (!escaped) {
34
- isInsideString = !isInsideString;
35
- }
36
- }
37
- if (isInsideString) {
38
- continue;
39
- }
40
- if (!isInsideComment && currentCharacter + nextCharacter === '//') {
41
- result += jsonString.slice(offset, index);
42
- offset = index;
43
- isInsideComment = singleComment;
44
- index++;
45
- }
46
- else if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
47
- index++;
48
- isInsideComment = false;
49
- result += strip(jsonString, offset, index);
50
- offset = index;
51
- continue;
52
- }
53
- else if (isInsideComment === singleComment && currentCharacter === '\n') {
54
- isInsideComment = false;
55
- result += strip(jsonString, offset, index);
56
- offset = index;
57
- }
58
- else if (!isInsideComment && currentCharacter + nextCharacter === '/*') {
59
- result += jsonString.slice(offset, index);
60
- offset = index;
61
- isInsideComment = multiComment;
62
- index++;
63
- continue;
64
- }
65
- else if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
66
- index++;
67
- isInsideComment = false;
68
- result += strip(jsonString, offset, index + 1);
69
- offset = index + 1;
70
- continue;
71
- }
72
- }
73
- return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
74
- }
75
- exports.stripJsonComments = stripJsonComments;
76
- //# sourceMappingURL=stripJsonComments.js.map