nestia 2.1.11 → 2.2.0-dev.20220625

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +28 -29
  2. package/lib/IConfiguration.d.ts +5 -6
  3. package/lib/NestiaApplication.d.ts +0 -1
  4. package/lib/NestiaApplication.js +12 -10
  5. package/lib/analyses/ControllerAnalyzer.d.ts +0 -1
  6. package/lib/analyses/ControllerAnalyzer.js +11 -5
  7. package/lib/analyses/GenericAnalyzer.d.ts +0 -1
  8. package/lib/analyses/GenericAnalyzer.js +1 -1
  9. package/lib/analyses/ImportAnalyzer.d.ts +2 -3
  10. package/lib/analyses/ImportAnalyzer.js +15 -5
  11. package/lib/analyses/ReflectAnalyzer.d.ts +0 -1
  12. package/lib/analyses/ReflectAnalyzer.js +19 -12
  13. package/lib/analyses/SourceFinder.d.ts +0 -1
  14. package/lib/executable/internal/CompilerOptions.d.ts +0 -1
  15. package/lib/executable/internal/CompilerOptions.js +3 -6
  16. package/lib/executable/internal/NestiaCommand.d.ts +0 -1
  17. package/lib/executable/internal/NestiaCommand.js +6 -6
  18. package/lib/executable/internal/NestiaConfig.d.ts +0 -1
  19. package/lib/executable/internal/NestiaConfig.js +574 -186
  20. package/lib/executable/internal/nestia.config.getter.d.ts +0 -1
  21. package/lib/executable/nestia.d.ts +0 -1
  22. package/lib/executable/nestia.js +1 -1
  23. package/lib/generates/FileGenerator.d.ts +0 -1
  24. package/lib/generates/FileGenerator.js +29 -24
  25. package/lib/generates/FunctionGenerator.d.ts +0 -1
  26. package/lib/generates/FunctionGenerator.js +69 -56
  27. package/lib/generates/SdkGenerator.d.ts +0 -1
  28. package/lib/generates/SwaggerGenerator.d.ts +0 -1
  29. package/lib/generates/SwaggerGenerator.js +89 -63
  30. package/lib/index.d.ts +0 -1
  31. package/lib/module.d.ts +0 -1
  32. package/lib/structures/IController.d.ts +0 -1
  33. package/lib/structures/IRoute.d.ts +3 -4
  34. package/lib/structures/ISwagger.d.ts +5 -1
  35. package/lib/structures/ITypeTuple.d.ts +5 -0
  36. package/lib/structures/{IMetadata.js → ITypeTuple.js} +1 -1
  37. package/lib/structures/MethodType.d.ts +0 -1
  38. package/lib/structures/MethodType.js +7 -1
  39. package/lib/structures/ParamCategory.d.ts +0 -1
  40. package/lib/structures/TypeEntry.d.ts +0 -1
  41. package/lib/structures/TypeEntry.js +3 -3
  42. package/lib/utils/ArrayUtil.d.ts +0 -1
  43. package/lib/utils/DirectoryUtil.d.ts +0 -1
  44. package/lib/utils/ImportDictionary.d.ts +0 -1
  45. package/lib/utils/ImportDictionary.js +4 -1
  46. package/lib/utils/MapUtil.d.ts +0 -1
  47. package/lib/utils/StringUtil.d.ts +0 -1
  48. package/package.json +11 -5
  49. package/lib/IConfiguration.d.ts.map +0 -1
  50. package/lib/NestiaApplication.d.ts.map +0 -1
  51. package/lib/analyses/ControllerAnalyzer.d.ts.map +0 -1
  52. package/lib/analyses/GenericAnalyzer.d.ts.map +0 -1
  53. package/lib/analyses/ImportAnalyzer.d.ts.map +0 -1
  54. package/lib/analyses/ReflectAnalyzer.d.ts.map +0 -1
  55. package/lib/analyses/SourceFinder.d.ts.map +0 -1
  56. package/lib/executable/internal/CompilerOptions.d.ts.map +0 -1
  57. package/lib/executable/internal/NestiaCommand.d.ts.map +0 -1
  58. package/lib/executable/internal/NestiaConfig.d.ts.map +0 -1
  59. package/lib/executable/internal/nestia.config.getter.d.ts.map +0 -1
  60. package/lib/executable/nestia.d.ts.map +0 -1
  61. package/lib/factories/TypeFactry.d.ts +0 -7
  62. package/lib/factories/TypeFactry.d.ts.map +0 -1
  63. package/lib/factories/TypeFactry.js +0 -76
  64. package/lib/generates/FileGenerator.d.ts.map +0 -1
  65. package/lib/generates/FunctionGenerator.d.ts.map +0 -1
  66. package/lib/generates/SdkGenerator.d.ts.map +0 -1
  67. package/lib/generates/SwaggerGenerator.d.ts.map +0 -1
  68. package/lib/index.d.ts.map +0 -1
  69. package/lib/module.d.ts.map +0 -1
  70. package/lib/structures/IController.d.ts.map +0 -1
  71. package/lib/structures/IMetadata.d.ts +0 -21
  72. package/lib/structures/IMetadata.d.ts.map +0 -1
  73. package/lib/structures/IRoute.d.ts.map +0 -1
  74. package/lib/structures/ISwagger.d.ts.map +0 -1
  75. package/lib/structures/IType.d.ts +0 -6
  76. package/lib/structures/IType.d.ts.map +0 -1
  77. package/lib/structures/IType.js +0 -3
  78. package/lib/structures/MethodType.d.ts.map +0 -1
  79. package/lib/structures/ParamCategory.d.ts.map +0 -1
  80. package/lib/structures/TypeEntry.d.ts.map +0 -1
  81. package/lib/utils/ArrayUtil.d.ts.map +0 -1
  82. package/lib/utils/DirectoryUtil.d.ts.map +0 -1
  83. package/lib/utils/ImportDictionary.d.ts.map +0 -1
  84. package/lib/utils/MapUtil.d.ts.map +0 -1
  85. package/lib/utils/StringUtil.d.ts.map +0 -1
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=nestia.config.getter.d.ts.map
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=nestia.d.ts.map
@@ -58,7 +58,7 @@ function install() {
58
58
  var e_1, _a;
59
59
  try {
60
60
  // INSTALL DEPENDENCIES
61
- for (var _b = __values(["nestia-fetcher", "typescript-is", "typescript-json"]), _c = _b.next(); !_c.done; _c = _b.next()) {
61
+ for (var _b = __values(["nestia-fetcher", "typescript-json"]), _c = _b.next(); !_c.done; _c = _b.next()) {
62
62
  var lib = _c.value;
63
63
  var command = "npm install ".concat(lib);
64
64
  child_process_1.default.execSync(command, { stdio: "inherit" });
@@ -3,4 +3,3 @@ import { IRoute } from "../structures/IRoute";
3
3
  export declare namespace FileGenerator {
4
4
  function generate(config: IConfiguration, routeList: IRoute[]): Promise<void>;
5
5
  }
6
- //# sourceMappingURL=FileGenerator.d.ts.map
@@ -148,10 +148,10 @@ var FileGenerator;
148
148
  }
149
149
  function relocate(directory) {
150
150
  var e_3, _a;
151
- if (directory.parent !== null
152
- && directory.directories.empty()
153
- && directory.routes.length === 1
154
- && directory.name === directory.routes[0].name) {
151
+ if (directory.parent !== null &&
152
+ directory.directories.empty() &&
153
+ directory.routes.length === 1 &&
154
+ directory.name === directory.routes[0].name) {
155
155
  directory.parent.routes.push(directory.routes[0]);
156
156
  directory.parent.directories.erase(directory.name);
157
157
  }
@@ -254,12 +254,18 @@ var FileGenerator;
254
254
  });
255
255
  // FINALIZE THE CONTENT
256
256
  if (directory.routes.length !== 0) {
257
- primitived = directory.routes.some(function (route) { return route.output.escapedText !== "void"
258
- || route.parameters.some(function (param) { return param.category !== "param"; }); });
259
- asserted = config.assert === true
260
- && directory.routes.some(function (route) { return route.parameters.length !== 0; });
261
- json = config.json === true
262
- && directory.routes.some(function (route) { return route.method === "POST" || route.method === "PUT" || route.method === "PATCH"; });
257
+ primitived = directory.routes.some(function (route) {
258
+ return route.output.name !== "void" ||
259
+ route.parameters.some(function (param) { return param.category !== "param"; });
260
+ });
261
+ asserted = config.assert === true &&
262
+ directory.routes.some(function (route) { return route.parameters.length !== 0; });
263
+ json = config.json === true &&
264
+ directory.routes.some(function (route) {
265
+ return route.method === "POST" ||
266
+ route.method === "PUT" ||
267
+ route.method === "PATCH";
268
+ });
263
269
  fetcher = ["Fetcher"];
264
270
  if (primitived)
265
271
  fetcher.push("Primitive");
@@ -267,21 +273,19 @@ var FileGenerator;
267
273
  "import { ".concat(fetcher.join(", "), " } from \"nestia-fetcher\";"),
268
274
  "import type { IConnection } from \"nestia-fetcher\";",
269
275
  ];
270
- if (asserted)
271
- head.push("import { assertType } from \"typescript-is\";");
272
- if (json)
273
- head.push("import { createStringifier } from \"typescript-json\";");
276
+ if (asserted || json)
277
+ head.push("import TSON from \"typescript-json\";");
274
278
  if (!importDict.empty())
275
279
  head.push("", importDict.toScript(outDir));
276
280
  content.push.apply(content, __spreadArray(__spreadArray(__spreadArray([], __read(head), false), [""], false), __read(content.splice(0, content.length)), false));
277
281
  }
278
- script = "/**\n"
279
- + " * @packageDocumentation\n"
280
- + " * @module ".concat(directory.module, "\n")
281
- + " * @nestia Generated by Nestia - https://github.com/samchon/nestia \n"
282
- + " */\n"
283
- + "//================================================================\n"
284
- + content.join("\n");
282
+ script = "/**\n" +
283
+ " * @packageDocumentation\n" +
284
+ " * @module ".concat(directory.module, "\n") +
285
+ " * @nestia Generated by Nestia - https://github.com/samchon/nestia \n" +
286
+ " */\n" +
287
+ "//================================================================\n" +
288
+ content.join("\n");
285
289
  return [4 /*yield*/, fs_1.default.promises.writeFile("".concat(outDir, "/index.ts"), script, "utf8")];
286
290
  case 12:
287
291
  _e.sent();
@@ -297,9 +301,10 @@ var Directory = /** @class */ (function () {
297
301
  this.name = name;
298
302
  this.directories = new HashMap_1.HashMap();
299
303
  this.routes = [];
300
- this.module = (this.parent !== null)
301
- ? "".concat(this.parent.module, ".").concat(name)
302
- : "api.".concat(name);
304
+ this.module =
305
+ this.parent !== null
306
+ ? "".concat(this.parent.module, ".").concat(name)
307
+ : "api.".concat(name);
303
308
  }
304
309
  return Directory;
305
310
  }());
@@ -3,4 +3,3 @@ import { IRoute } from "../structures/IRoute";
3
3
  export declare namespace FunctionGenerator {
4
4
  function generate(config: IConfiguration, route: IRoute): string;
5
5
  }
6
- //# sourceMappingURL=FunctionGenerator.d.ts.map
@@ -60,7 +60,7 @@ var FunctionGenerator;
60
60
  "connection",
61
61
  "".concat(route.name, ".ENCRYPTED"),
62
62
  "".concat(route.name, ".METHOD"),
63
- "".concat(route.name, ".path(").concat(parameters.map(function (p) { return p.name; }).join(", "), ")")
63
+ "".concat(route.name, ".path(").concat(parameters.map(function (p) { return p.name; }).join(", "), ")"),
64
64
  ];
65
65
  if (input !== undefined) {
66
66
  fetchArguments.push(input.name);
@@ -69,17 +69,20 @@ var FunctionGenerator;
69
69
  }
70
70
  var assertions = config.assert === true && route.parameters.length !== 0
71
71
  ? route.parameters
72
- .map(function (param) { return " assertType<typeof ".concat(param.name, ">(").concat(param.name, ");"); })
72
+ .map(function (param) {
73
+ return " assertType<typeof ".concat(param.name, ">(").concat(param.name, ");");
74
+ })
73
75
  .join("\n") + "\n\n"
74
76
  : "";
75
77
  // RETURNS WITH FINALIZATION
76
- return "{\n"
77
- + assertions
78
- + " return Fetcher.fetch\n"
79
- + " (\n"
80
- + fetchArguments.map(function (param) { return " ".concat(param); }).join(",\n") + "\n"
81
- + " );\n"
82
- + "}";
78
+ return ("{\n" +
79
+ assertions +
80
+ " return Fetcher.fetch\n" +
81
+ " (\n" +
82
+ fetchArguments.map(function (param) { return " ".concat(param); }).join(",\n") +
83
+ "\n" +
84
+ " );\n" +
85
+ "}");
83
86
  }
84
87
  function filter_parameters(route, query) {
85
88
  var parameters = route.parameters.filter(function (param) { return param.category === "param"; });
@@ -114,20 +117,24 @@ var FunctionGenerator;
114
117
  text: [
115
118
  {
116
119
  kind: "parameterName",
117
- text: "connection"
120
+ text: "connection",
118
121
  },
119
122
  {
120
123
  kind: "space",
121
- text: " "
124
+ text: " ",
122
125
  },
123
126
  {
124
127
  kind: "text",
125
- text: "connection Information of the remote HTTP(s) server with headers (+encryption password)"
126
- }
127
- ]
128
+ text: "connection Information of the remote HTTP(s) server with headers (+encryption password)",
129
+ },
130
+ ],
128
131
  });
129
132
  }
130
- comments.push.apply(comments, __spreadArray(__spreadArray([], __read(tagList.map(function (tag) { return "@".concat(tag.name, " ").concat(tag.text.map(function (elem) { return elem.text; }).join("")); })), false), [""], false));
133
+ comments.push.apply(comments, __spreadArray(__spreadArray([], __read(tagList.map(function (tag) {
134
+ return "@".concat(tag.name, " ").concat(tag
135
+ .text.map(function (elem) { return elem.text; })
136
+ .join(""));
137
+ })), false), [""], false));
131
138
  }
132
139
  // COMPLETE THE COMMENT
133
140
  comments.push("@controller ".concat(route.symbol), "@path ".concat(route.method, " ").concat(route.path), "@nestia Generated by Nestia - https://github.com/samchon/nestia");
@@ -138,60 +145,66 @@ var FunctionGenerator;
138
145
  var parameters = __spreadArray([
139
146
  "connection: IConnection"
140
147
  ], __read(route.parameters.map(function (param) {
141
- var type = (param === query || param === input)
148
+ var type = param === query || param === input
142
149
  ? "Primitive<".concat(route.name, ".").concat(param === query ? "Query" : "Input", ">")
143
- : param.type.escapedText;
150
+ : param.type.name;
144
151
  return "".concat(param.name, ": ").concat(type);
145
152
  })), false);
146
153
  // OUTPUT TYPE
147
- var output = route.output.escapedText === "void"
148
- ? "void"
149
- : "".concat(route.name, ".Output");
154
+ var output = route.output.name === "void" ? "void" : "".concat(route.name, ".Output");
150
155
  // RETURNS WITH CONSTRUCTION
151
- return ""
152
- + "/**\n"
153
- + comments.map(function (str) { return " * ".concat(str); }).join("\n") + "\n"
154
- + " */\n"
155
- + "export function ".concat(route.name, "\n")
156
- + " (\n"
157
- + "".concat(parameters.map(function (str) { return " ".concat(str); }).join(",\n"), "\n")
158
- + " ): Promise<".concat(output, ">");
156
+ return ("" +
157
+ "/**\n" +
158
+ comments.map(function (str) { return " * ".concat(str); }).join("\n") +
159
+ "\n" +
160
+ " */\n" +
161
+ "export function ".concat(route.name, "\n") +
162
+ " (\n" +
163
+ "".concat(parameters.map(function (str) { return " ".concat(str); }).join(",\n"), "\n") +
164
+ " ): Promise<".concat(output, ">"));
159
165
  }
160
166
  function tail(route, query, input, config) {
161
167
  // LIST UP TYPES
162
168
  var types = [];
163
169
  if (query !== undefined)
164
- types.push(new Pair_1.Pair("Query", query.type.escapedText));
170
+ types.push(new Pair_1.Pair("Query", query.type.name));
165
171
  if (input !== undefined)
166
- types.push(new Pair_1.Pair("Input", input.type.escapedText));
167
- if (route.output.escapedText !== "void")
168
- types.push(new Pair_1.Pair("Output", route.output.escapedText));
172
+ types.push(new Pair_1.Pair("Input", input.type.name));
173
+ if (route.output.name !== "void")
174
+ types.push(new Pair_1.Pair("Output", route.output.name));
169
175
  // PATH WITH PARAMETERS
170
176
  var parameters = filter_parameters(route, query);
171
177
  var path = compute_path(query, parameters, route.path);
172
- return "export namespace ".concat(route.name, "\n")
173
- + "{\n"
174
- +
175
- (types.length !== 0
176
- ? types.map(function (tuple) { return " export type ".concat(tuple.first, " = Primitive<").concat(tuple.second, ">;"); }).join("\n") + "\n"
177
- : "")
178
- + "\n"
179
- + " export const METHOD = \"".concat(route.method, "\" as const;\n")
180
- + " export const PATH: string = \"".concat(route.path, "\";\n")
181
- + " export const ENCRYPTED: Fetcher.IEncrypted = {\n"
182
- + " request: ".concat(input !== undefined && input.encrypted, ",\n")
183
- + " response: ".concat(route.encrypted, ",\n")
184
- + " };\n"
185
- + "\n"
186
- + " export function path(".concat(parameters.map(function (param) { return "".concat(param.name, ": ").concat(param.type.escapedText); }).join(", "), "): string\n")
187
- + " {\n"
188
- + " return ".concat(path, ";\n")
189
- + " }\n"
190
- +
191
- (config.json === true && (route.method === "POST" || route.method === "PUT" || route.method === "PATCH")
192
- ? " export const stringify = createStringifier<Input>();\n"
193
- : "")
194
- + "}";
178
+ return ("export namespace ".concat(route.name, "\n") +
179
+ "{\n" +
180
+ (types.length !== 0
181
+ ? types
182
+ .map(function (tuple) {
183
+ return " export type ".concat(tuple.first, " = Primitive<").concat(tuple.second, ">;");
184
+ })
185
+ .join("\n") + "\n"
186
+ : "") +
187
+ "\n" +
188
+ " export const METHOD = \"".concat(route.method, "\" as const;\n") +
189
+ " export const PATH: string = \"".concat(route.path, "\";\n") +
190
+ " export const ENCRYPTED: Fetcher.IEncrypted = {\n" +
191
+ " request: ".concat(input !== undefined && input.encrypted, ",\n") +
192
+ " response: ".concat(route.encrypted, ",\n") +
193
+ " };\n" +
194
+ "\n" +
195
+ " export function path(".concat(parameters
196
+ .map(function (param) { return "".concat(param.name, ": ").concat(param.type.name); })
197
+ .join(", "), "): string\n") +
198
+ " {\n" +
199
+ " return ".concat(path, ";\n") +
200
+ " }\n" +
201
+ (config.json === true &&
202
+ (route.method === "POST" ||
203
+ route.method === "PUT" ||
204
+ route.method === "PATCH")
205
+ ? " export const stringify = createStringifier<Input>();\n"
206
+ : "") +
207
+ "}");
195
208
  }
196
209
  function compute_path(query, parameters, path) {
197
210
  var e_1, _a;
@@ -209,7 +222,7 @@ var FunctionGenerator;
209
222
  }
210
223
  finally { if (e_1) throw e_1.error; }
211
224
  }
212
- return (query !== undefined)
225
+ return query !== undefined
213
226
  ? "`".concat(path, "?${new URLSearchParams(").concat(query.name, " as any).toString()}`")
214
227
  : "`".concat(path, "`");
215
228
  }
@@ -5,4 +5,3 @@ export declare namespace SdkGenerator {
5
5
  function generate(_checker: ts.TypeChecker, config: IConfiguration, routeList: IRoute[]): Promise<void>;
6
6
  const BUNDLE_PATH: string;
7
7
  }
8
- //# sourceMappingURL=SdkGenerator.d.ts.map
@@ -4,4 +4,3 @@ import { IRoute } from "../structures/IRoute";
4
4
  export declare namespace SwaggerGenerator {
5
5
  function generate(checker: ts.TypeChecker, config: IConfiguration.ISwagger, routeList: IRoute[]): Promise<void>;
6
6
  }
7
- //# sourceMappingURL=SwaggerGenerator.d.ts.map
@@ -83,15 +83,15 @@ var path_1 = __importDefault(require("path"));
83
83
  var Singleton_1 = require("tstl/thread/Singleton");
84
84
  var VariadicSingleton_1 = require("tstl/thread/VariadicSingleton");
85
85
  var CommentFactory_1 = require("typescript-json/lib/factories/CommentFactory");
86
- var MetadataCollection_1 = require("typescript-json/lib/storages/MetadataCollection");
86
+ var ApplicationProgrammer_1 = require("typescript-json/lib/programmers/ApplicationProgrammer");
87
+ var MetadataCollection_1 = require("typescript-json/lib/factories/MetadataCollection");
87
88
  var MetadataFactory_1 = require("typescript-json/lib/factories/MetadataFactory");
88
- var SchemaFactory_1 = require("typescript-json/lib/factories/SchemaFactory");
89
89
  var MapUtil_1 = require("../utils/MapUtil");
90
90
  var SwaggerGenerator;
91
91
  (function (SwaggerGenerator) {
92
92
  function generate(checker, config, routeList) {
93
93
  return __awaiter(this, void 0, void 0, function () {
94
- var parsed, location, swagger, collection, pathDict, routeList_1, routeList_1_1, route, path, pathDict_1, pathDict_1_1, _a, path, routes;
94
+ var parsed, location, collection, tupleList, swagger, pathDict, routeList_1, routeList_1_1, route, path, pathDict_1, pathDict_1_1, _a, path, routes, application;
95
95
  var e_1, _b, e_2, _c;
96
96
  return __generator(this, function (_d) {
97
97
  switch (_d.label) {
@@ -100,16 +100,19 @@ var SwaggerGenerator;
100
100
  location = !!parsed.ext
101
101
  ? path_1.default.resolve(config.output)
102
102
  : path_1.default.join(path_1.default.resolve(config.output), "swagger.json");
103
+ collection = new MetadataCollection_1.MetadataCollection({
104
+ replace: MetadataCollection_1.MetadataCollection.replace
105
+ });
106
+ tupleList = [];
103
107
  return [4 /*yield*/, initialize(location)];
104
108
  case 1:
105
109
  swagger = _d.sent();
106
- collection = new MetadataCollection_1.MetadataCollection(false);
107
110
  pathDict = new Map();
108
111
  try {
109
112
  for (routeList_1 = __values(routeList), routeList_1_1 = routeList_1.next(); !routeList_1_1.done; routeList_1_1 = routeList_1.next()) {
110
113
  route = routeList_1_1.value;
111
114
  path = MapUtil_1.MapUtil.take(pathDict, get_path(route.path, route.parameters), function () { return ({}); });
112
- path[route.method.toLowerCase()] = generate_route(checker, collection, route);
115
+ path[route.method.toLowerCase()] = generate_route(checker, collection, tupleList, route);
113
116
  }
114
117
  }
115
118
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -133,8 +136,17 @@ var SwaggerGenerator;
133
136
  }
134
137
  finally { if (e_2) throw e_2.error; }
135
138
  }
136
- // CONSTRUCT COMPONENTS
137
- swagger.components = SchemaFactory_1.SchemaFactory.components(collection.storage());
139
+ application = ApplicationProgrammer_1.ApplicationProgrammer.generate(tupleList.map(function (_a) {
140
+ var metadata = _a.metadata;
141
+ return metadata;
142
+ }), {
143
+ purpose: "swagger",
144
+ });
145
+ swagger.components = __assign(__assign({}, (swagger.components || {})), { schemas: application.components.schemas });
146
+ tupleList.forEach(function (_a, index) {
147
+ var schema = _a.schema;
148
+ Object.assign(schema, application.schemas[index]);
149
+ });
138
150
  // DO GENERATE
139
151
  return [4 /*yield*/, fs_1.default.promises.writeFile(location, JSON.stringify(swagger, null, 2), "utf8")];
140
152
  case 2:
@@ -164,12 +176,18 @@ var SwaggerGenerator;
164
176
  case 2:
165
177
  _a = {
166
178
  openapi: "3.0.1",
179
+ servers: [
180
+ {
181
+ url: "https://github.com/samchon/nestia",
182
+ description: "insert your server url",
183
+ },
184
+ ],
167
185
  info: {
168
186
  version: "0.1.0",
169
- title: "Generated by nestia - https://github.com/samchon/nestia"
187
+ title: "Generated by nestia - https://github.com/samchon/nestia",
170
188
  },
171
189
  paths: {},
172
- components: {}
190
+ components: {},
173
191
  };
174
192
  _d.label = 3;
175
193
  case 3:
@@ -182,8 +200,7 @@ var SwaggerGenerator;
182
200
  }
183
201
  function get_path(path, parameters) {
184
202
  var e_3, _a;
185
- var filtered = parameters.filter(function (param) { return param.category === "param"
186
- && !!param.field; });
203
+ var filtered = parameters.filter(function (param) { return param.category === "param" && !!param.field; });
187
204
  try {
188
205
  for (var filtered_1 = __values(filtered), filtered_1_1 = filtered_1.next(); !filtered_1_1.done; filtered_1_1 = filtered_1.next()) {
189
206
  var param = filtered_1_1.value;
@@ -199,78 +216,76 @@ var SwaggerGenerator;
199
216
  }
200
217
  return path;
201
218
  }
202
- function generate_route(checker, collection, route) {
219
+ function generate_route(checker, collection, tupleList, route) {
203
220
  var bodyParam = route.parameters.find(function (param) { return param.category === "body"; });
204
221
  var tags = route.tags
205
222
  .filter(function (tag) {
206
223
  return tag.name === "tag" &&
207
224
  tag.text &&
208
- tag.text.find(function (elem) {
209
- return elem.kind === "text" &&
210
- elem.text.length;
211
- }) !== undefined;
225
+ tag.text.find(function (elem) { return elem.kind === "text" && elem.text.length; }) !== undefined;
212
226
  })
213
227
  .map(function (tag) { return tag.text.find(function (elem) { return elem.kind === "text"; }).text; });
214
- var encrypted = route.encrypted === true
215
- || !!route.parameters.find(function (param) { return param.encrypted === true; });
228
+ var encrypted = route.encrypted === true ||
229
+ !!route.parameters.find(function (param) { return param.encrypted === true; });
216
230
  return {
217
231
  tags: tags,
218
232
  summary: encrypted ? "encrypted" : undefined,
219
233
  parameters: route.parameters
220
234
  .filter(function (param) { return param.category !== "body"; })
221
- .map(function (param) { return generate_parameter(checker, collection, route, param); }),
235
+ .map(function (param) {
236
+ return generate_parameter(checker, collection, tupleList, route, param);
237
+ }),
222
238
  requestBody: bodyParam
223
- ? generate_request_body(checker, collection, route, bodyParam)
239
+ ? generate_request_body(checker, collection, tupleList, route, bodyParam)
224
240
  : undefined,
225
- responses: generate_response_body(checker, collection, route),
226
- description: CommentFactory_1.CommentFactory.generate(route.comments)
241
+ responses: generate_response_body(checker, collection, tupleList, route),
242
+ description: CommentFactory_1.CommentFactory.generate(route.comments),
227
243
  };
228
244
  }
229
245
  /* ---------------------------------------------------------
230
246
  REQUEST & RESPONSE
231
247
  --------------------------------------------------------- */
232
- function generate_parameter(checker, collection, route, parameter) {
248
+ function generate_parameter(checker, collection, tupleList, route, parameter) {
233
249
  return {
234
250
  name: parameter.field || parameter.name,
235
- in: parameter.category === "param"
236
- ? "path"
237
- : parameter.category,
238
- description: get_parametric_description(route, "param", parameter.name) || "",
239
- schema: generate_schema(checker, collection, parameter.type.metadata),
240
- required: true
251
+ in: parameter.category === "param" ? "path" : parameter.category,
252
+ description: get_parametric_description(route, "param", parameter.name) ||
253
+ "",
254
+ schema: generate_schema(checker, collection, tupleList, parameter.type.type),
255
+ required: true,
241
256
  };
242
257
  }
243
- function generate_request_body(checker, collection, route, parameter) {
258
+ function generate_request_body(checker, collection, tupleList, route, parameter) {
244
259
  return {
245
- description: warning.get(parameter.encrypted).get("request")
246
- + (get_parametric_description(route, "param", parameter.name) || ""),
260
+ description: warning.get(parameter.encrypted).get("request") +
261
+ (get_parametric_description(route, "param", parameter.name) ||
262
+ ""),
247
263
  content: {
248
264
  "application/json": {
249
- schema: generate_schema(checker, collection, parameter.type.metadata)
250
- }
265
+ schema: generate_schema(checker, collection, tupleList, parameter.type.type),
266
+ },
251
267
  },
252
- required: true
268
+ required: true,
253
269
  };
254
270
  }
255
- function generate_response_body(checker, collection, route) {
271
+ function generate_response_body(checker, collection, tupleList, route) {
256
272
  var _a;
257
273
  // OUTPUT WITH SUCCESS STATUS
258
- var status = route.method === "GET" || route.method === "DELETE"
259
- ? "200"
260
- : "201";
261
- var schema = generate_schema(checker, collection, route.output.metadata);
274
+ var status = route.method === "GET" || route.method === "DELETE" ? "200" : "201";
275
+ var schema = generate_schema(checker, collection, tupleList, route.output.type);
262
276
  var success = (_a = {},
263
277
  _a[status] = {
264
- description: warning.get(route.encrypted).get("response", route.method)
265
- + (get_parametric_description(route, "return")
266
- || get_parametric_description(route, "returns")
267
- || ""),
268
- content: route.output.escapedText === "void" ? undefined :
269
- {
278
+ description: warning.get(route.encrypted).get("response", route.method) +
279
+ (get_parametric_description(route, "return") ||
280
+ get_parametric_description(route, "returns") ||
281
+ ""),
282
+ content: route.output.name === "void"
283
+ ? undefined
284
+ : {
270
285
  "application/json": {
271
- schema: schema
272
- }
273
- }
286
+ schema: schema,
287
+ },
288
+ },
274
289
  },
275
290
  _a);
276
291
  // EXCEPTION STATUSES
@@ -280,17 +295,21 @@ var SwaggerGenerator;
280
295
  tag.text &&
281
296
  tag.text.find(function (elem) {
282
297
  return elem.kind === "text" &&
283
- isNaN(Number(elem.text.split(" ").map(function (str) { return str.trim(); })[0])) === false;
298
+ isNaN(Number(elem.text
299
+ .split(" ")
300
+ .map(function (str) { return str.trim(); })[0])) === false;
284
301
  }) !== undefined;
285
302
  })
286
303
  .map(function (tag) {
287
304
  var text = tag.text.find(function (elem) { return elem.kind === "text"; }).text;
288
- var elements = text.split(" ").map(function (str) { return str.trim(); });
305
+ var elements = text
306
+ .split(" ")
307
+ .map(function (str) { return str.trim(); });
289
308
  return [
290
309
  elements[0],
291
310
  {
292
311
  description: elements.slice(1).join(" "),
293
- }
312
+ },
294
313
  ];
295
314
  }));
296
315
  return __assign(__assign({}, exceptions), success);
@@ -298,21 +317,26 @@ var SwaggerGenerator;
298
317
  /* ---------------------------------------------------------
299
318
  UTILS
300
319
  --------------------------------------------------------- */
301
- function generate_schema(checker, collection, type) {
302
- var entity = MetadataFactory_1.MetadataFactory.generate(checker, type, collection);
303
- return SchemaFactory_1.SchemaFactory.schema((entity === null || entity === void 0 ? void 0 : entity.metadata) || null);
320
+ function generate_schema(checker, collection, tupleList, type) {
321
+ var metadata = MetadataFactory_1.MetadataFactory.generate(checker, collection, type, {
322
+ resolve: false,
323
+ constant: true,
324
+ });
325
+ var schema = {};
326
+ tupleList.push({ metadata: metadata, schema: schema });
327
+ return schema;
304
328
  }
305
329
  function get_parametric_description(route, tagName, parameterName) {
306
330
  var _a;
307
331
  var parametric = parameterName
308
- ? function (tag) { return tag.text.find(function (elem) { return elem.kind === "parameterName"
309
- && elem.text === parameterName; }) !== undefined; }
332
+ ? function (tag) {
333
+ return tag.text.find(function (elem) {
334
+ return elem.kind === "parameterName" &&
335
+ elem.text === parameterName;
336
+ }) !== undefined;
337
+ }
310
338
  : function () { return true; };
311
- var tag = route.tags.find(function (tag) {
312
- return tag.name === tagName &&
313
- tag.text &&
314
- parametric(tag);
315
- });
339
+ var tag = route.tags.find(function (tag) { return tag.name === tagName && tag.text && parametric(tag); });
316
340
  return tag && tag.text
317
341
  ? (_a = tag.text.find(function (elem) { return elem.kind === "text"; })) === null || _a === void 0 ? void 0 : _a.text
318
342
  : undefined;
@@ -327,7 +351,9 @@ var warning = new VariadicSingleton_1.VariadicSingleton(function (encrypted) {
327
351
  : "Response data have been encrypted.";
328
352
  var component = type === "request"
329
353
  ? "[EncryptedBody](https://github.com/samchon/nestia-helper#encryptedbody)"
330
- : "[EncryptedRoute.".concat(method[0].toUpperCase(), ".").concat(method.substring(1).toLowerCase(), "](https://github.com/samchon/nestia-helper#encryptedroute)");
354
+ : "[EncryptedRoute.".concat(method[0].toUpperCase(), ".").concat(method
355
+ .substring(1)
356
+ .toLowerCase(), "](https://github.com/samchon/nestia-helper#encryptedroute)");
331
357
  return "## Warning\n".concat(summary, "\n\nThe ").concat(type, " body data would be encrypted as \"AES-128(256) / CBC mode / PKCS#5 Padding / Base64 Encoding\", through the ").concat(component, " component.\n\nTherefore, just utilize this swagger editor only for referencing. If you need to call the real API, using [SDK](https://github.com/samchon/nestia#software-development-kit) would be much better.\n\n-----------------\n\n");
332
358
  });
333
359
  });
package/lib/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  import * as nestia from "./module";
2
2
  export default nestia;
3
- //# sourceMappingURL=index.d.ts.map
package/lib/module.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./IConfiguration";
2
2
  export * from "./NestiaApplication";
3
- //# sourceMappingURL=module.d.ts.map
@@ -21,4 +21,3 @@ export declare namespace IController {
21
21
  encrypted: boolean;
22
22
  }
23
23
  }
24
- //# sourceMappingURL=IController.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import ts from "typescript";
2
- import { IType } from "./IType";
2
+ import { ITypeTuple } from "./ITypeTuple";
3
3
  import { ParamCategory } from "./ParamCategory";
4
4
  export interface IRoute {
5
5
  name: string;
@@ -8,7 +8,7 @@ export interface IRoute {
8
8
  encrypted: boolean;
9
9
  parameters: IRoute.IParameter[];
10
10
  imports: [string, string[]][];
11
- output: IType;
11
+ output: ITypeTuple;
12
12
  symbol: string;
13
13
  comments: ts.SymbolDisplayPart[];
14
14
  tags: ts.JSDocTagInfo[];
@@ -19,7 +19,6 @@ export declare namespace IRoute {
19
19
  field: string | undefined;
20
20
  category: ParamCategory;
21
21
  encrypted: boolean;
22
- type: IType;
22
+ type: ITypeTuple;
23
23
  }
24
24
  }
25
- //# sourceMappingURL=IRoute.d.ts.map