nestia 2.1.0-dev.20220414 → 2.1.0-dev.20220430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/.github/workflows/build.yml +2 -4
  2. package/README.md +84 -14
  3. package/{src/bundle → bundle}/HttpError.ts +0 -0
  4. package/{src/bundle → bundle}/IConnection.ts +0 -0
  5. package/{src/bundle → bundle}/Primitive.ts +0 -0
  6. package/{src/bundle → bundle}/__internal/AesPkcs5.ts +0 -0
  7. package/{src/bundle → bundle}/__internal/Fetcher.ts +0 -0
  8. package/lib/IConfiguration.d.ts +71 -0
  9. package/lib/IConfiguration.d.ts.map +1 -0
  10. package/lib/IConfiguration.js +3 -0
  11. package/lib/NestiaApplication.d.ts +12 -0
  12. package/lib/NestiaApplication.d.ts.map +1 -0
  13. package/lib/NestiaApplication.js +340 -0
  14. package/lib/analyses/ControllerAnalyzer.d.ts +7 -0
  15. package/lib/analyses/ControllerAnalyzer.d.ts.map +1 -0
  16. package/lib/analyses/ControllerAnalyzer.js +191 -0
  17. package/lib/analyses/GenericAnalyzer.d.ts +6 -0
  18. package/lib/analyses/GenericAnalyzer.d.ts.map +1 -0
  19. package/lib/analyses/GenericAnalyzer.js +100 -0
  20. package/lib/analyses/ImportAnalyzer.d.ts +14 -0
  21. package/lib/analyses/ImportAnalyzer.d.ts.map +1 -0
  22. package/lib/analyses/ImportAnalyzer.js +79 -0
  23. package/lib/analyses/ReflectAnalyzer.d.ts +5 -0
  24. package/lib/analyses/ReflectAnalyzer.d.ts.map +1 -0
  25. package/lib/analyses/ReflectAnalyzer.js +313 -0
  26. package/lib/analyses/SourceFinder.d.ts +5 -0
  27. package/lib/analyses/SourceFinder.d.ts.map +1 -0
  28. package/lib/analyses/SourceFinder.js +260 -0
  29. package/lib/executable/internal/CompilerOptions.d.ts +14 -0
  30. package/lib/executable/internal/CompilerOptions.d.ts.map +1 -0
  31. package/lib/executable/internal/CompilerOptions.js +126 -0
  32. package/lib/executable/internal/NestiaCommand.d.ts +5 -0
  33. package/lib/executable/internal/NestiaCommand.d.ts.map +1 -0
  34. package/lib/executable/internal/NestiaCommand.js +228 -0
  35. package/lib/executable/internal/NestiaConfig.d.ts +5 -0
  36. package/lib/executable/internal/NestiaConfig.d.ts.map +1 -0
  37. package/lib/executable/internal/NestiaConfig.js +277 -0
  38. package/lib/executable/internal/nestia.config.getter.d.ts +2 -0
  39. package/lib/executable/internal/nestia.config.getter.d.ts.map +1 -0
  40. package/lib/executable/internal/nestia.config.getter.js +60 -0
  41. package/lib/executable/nestia.d.ts +3 -0
  42. package/lib/executable/nestia.d.ts.map +1 -0
  43. package/lib/executable/nestia.js +129 -0
  44. package/lib/generates/FileGenerator.d.ts +6 -0
  45. package/lib/generates/FileGenerator.d.ts.map +1 -0
  46. package/lib/generates/FileGenerator.js +326 -0
  47. package/lib/generates/FunctionGenerator.d.ts +6 -0
  48. package/lib/generates/FunctionGenerator.d.ts.map +1 -0
  49. package/lib/generates/FunctionGenerator.js +217 -0
  50. package/lib/generates/SdkGenerator.d.ts +8 -0
  51. package/lib/generates/SdkGenerator.d.ts.map +1 -0
  52. package/lib/generates/SdkGenerator.js +128 -0
  53. package/lib/generates/SwaggerGenerator.d.ts +7 -0
  54. package/lib/generates/SwaggerGenerator.d.ts.map +1 -0
  55. package/lib/generates/SwaggerGenerator.js +258 -0
  56. package/lib/index.d.ts +3 -0
  57. package/lib/index.d.ts.map +1 -0
  58. package/lib/index.js +28 -0
  59. package/lib/module.d.ts +3 -0
  60. package/lib/module.d.ts.map +1 -0
  61. package/lib/module.js +19 -0
  62. package/{src/structures/IController.ts → lib/structures/IController.d.ts} +6 -13
  63. package/lib/structures/IController.d.ts.map +1 -0
  64. package/lib/structures/IController.js +3 -0
  65. package/{src/structures/IRoute.ts → lib/structures/IRoute.d.ts} +8 -13
  66. package/lib/structures/IRoute.d.ts.map +1 -0
  67. package/lib/structures/IRoute.js +3 -0
  68. package/lib/structures/ISwagger.d.ts +36 -0
  69. package/lib/structures/ISwagger.d.ts.map +1 -0
  70. package/lib/structures/ISwagger.js +3 -0
  71. package/lib/structures/IType.d.ts +6 -0
  72. package/lib/structures/IType.d.ts.map +1 -0
  73. package/lib/structures/IType.js +3 -0
  74. package/lib/structures/MethodType.d.ts +5 -0
  75. package/lib/structures/MethodType.d.ts.map +1 -0
  76. package/lib/structures/MethodType.js +8 -0
  77. package/lib/structures/ParamCategory.d.ts +2 -0
  78. package/lib/structures/ParamCategory.d.ts.map +1 -0
  79. package/lib/structures/ParamCategory.js +3 -0
  80. package/lib/utils/ArrayUtil.d.ts +6 -0
  81. package/lib/utils/ArrayUtil.d.ts.map +1 -0
  82. package/lib/utils/ArrayUtil.js +144 -0
  83. package/lib/utils/DirectoryUtil.d.ts +6 -0
  84. package/lib/utils/DirectoryUtil.d.ts.map +1 -0
  85. package/lib/utils/DirectoryUtil.js +190 -0
  86. package/lib/utils/ImportDictionary.d.ts +7 -0
  87. package/lib/utils/ImportDictionary.d.ts.map +1 -0
  88. package/lib/utils/ImportDictionary.js +83 -0
  89. package/lib/utils/MapUtil.d.ts +4 -0
  90. package/lib/utils/MapUtil.d.ts.map +1 -0
  91. package/lib/utils/MapUtil.js +16 -0
  92. package/lib/utils/StringUtil.d.ts +4 -0
  93. package/lib/utils/StringUtil.d.ts.map +1 -0
  94. package/lib/utils/StringUtil.js +13 -0
  95. package/package.json +17 -10
  96. package/src/IConfiguration.ts +0 -17
  97. package/src/NestiaApplication.ts +0 -96
  98. package/src/analyses/ControllerAnalyzer.ts +0 -154
  99. package/src/analyses/GenericAnalyzer.ts +0 -52
  100. package/src/analyses/ImportAnalyzer.ts +0 -93
  101. package/src/analyses/ReflectAnalyzer.ts +0 -221
  102. package/src/analyses/SourceFinder.ts +0 -73
  103. package/src/bin/nestia.ts +0 -125
  104. package/src/executable/sdk.ts +0 -89
  105. package/src/generates/FileGenerator.ts +0 -150
  106. package/src/generates/FunctionGenerator.ts +0 -201
  107. package/src/generates/SdkGenerator.ts +0 -39
  108. package/src/internal/CompilerOptions.ts +0 -142
  109. package/src/structures/MethodType.ts +0 -6
  110. package/src/structures/ParamCategory.ts +0 -1
  111. package/src/utils/ArrayUtil.ts +0 -26
  112. package/src/utils/DirectoryUtil.ts +0 -48
  113. package/src/utils/ImportDictionary.ts +0 -44
  114. package/src/utils/StringUtil.ts +0 -10
  115. package/src/utils/stripJsonComments.ts +0 -79
  116. package/tsconfig.json +0 -82
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __read = (this && this.__read) || function (o, n) {
37
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
38
+ if (!m) return o;
39
+ var i = m.call(o), r, ar = [], e;
40
+ try {
41
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42
+ }
43
+ catch (error) { e = { error: error }; }
44
+ finally {
45
+ try {
46
+ if (r && !r.done && (m = i["return"])) m.call(i);
47
+ }
48
+ finally { if (e) throw e.error; }
49
+ }
50
+ return ar;
51
+ };
52
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
53
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
54
+ if (ar || !(i in from)) {
55
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
56
+ ar[i] = from[i];
57
+ }
58
+ }
59
+ return to.concat(ar || Array.prototype.slice.call(from));
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.ControllerAnalyzer = void 0;
74
+ var NodePath = __importStar(require("path"));
75
+ var tsc = __importStar(require("typescript"));
76
+ var HashMap_1 = require("tstl/container/HashMap");
77
+ var GenericAnalyzer_1 = require("./GenericAnalyzer");
78
+ var ImportAnalyzer_1 = require("./ImportAnalyzer");
79
+ var ControllerAnalyzer;
80
+ (function (ControllerAnalyzer) {
81
+ function analyze(checker, sourceFile, controller) {
82
+ // FIND CONTROLLER CLASS
83
+ var ret = [];
84
+ tsc.forEachChild(sourceFile, function (node) {
85
+ var _a;
86
+ if (tsc.isClassDeclaration(node) && ((_a = node.name) === null || _a === void 0 ? void 0 : _a.escapedText) === controller.name) {
87
+ // ANALYZE THE CONTROLLER
88
+ ret.push.apply(ret, __spreadArray([], __read(_Analyze_controller(checker, controller, node)), false));
89
+ return;
90
+ }
91
+ });
92
+ return ret;
93
+ }
94
+ ControllerAnalyzer.analyze = analyze;
95
+ /* ---------------------------------------------------------
96
+ CLASS
97
+ --------------------------------------------------------- */
98
+ function _Analyze_controller(checker, controller, classNode) {
99
+ var e_1, _a, e_2, _b;
100
+ var ret = [];
101
+ var classType = checker.getTypeAtLocation(classNode);
102
+ var genericDict = GenericAnalyzer_1.GenericAnalyzer.analyze(checker, classNode);
103
+ try {
104
+ for (var _c = __values(classType.getProperties()), _d = _c.next(); !_d.done; _d = _c.next()) {
105
+ var property = _d.value;
106
+ if (property.declarations) {
107
+ var _loop_1 = function (declaration) {
108
+ // TARGET ONLY METHOD
109
+ if (!tsc.isMethodDeclaration(declaration))
110
+ return "continue";
111
+ // IT MUST BE
112
+ var identifier = declaration.name;
113
+ if (!tsc.isIdentifier(identifier))
114
+ return "continue";
115
+ // ANALYZED WITH THE REFLECTED-FUNCTION
116
+ var func = controller.functions.find(function (f) { return f.name === identifier.escapedText; });
117
+ if (func !== undefined)
118
+ ret.push(_Analyze_function(checker, controller, genericDict, func, declaration));
119
+ };
120
+ try {
121
+ for (var _e = (e_2 = void 0, __values(property.declarations)), _f = _e.next(); !_f.done; _f = _e.next()) {
122
+ var declaration = _f.value;
123
+ _loop_1(declaration);
124
+ }
125
+ }
126
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
127
+ finally {
128
+ try {
129
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
130
+ }
131
+ finally { if (e_2) throw e_2.error; }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
137
+ finally {
138
+ try {
139
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
140
+ }
141
+ finally { if (e_1) throw e_1.error; }
142
+ }
143
+ return ret;
144
+ }
145
+ /* ---------------------------------------------------------
146
+ FUNCTION
147
+ --------------------------------------------------------- */
148
+ function _Analyze_function(checker, controller, genericDict, func, declaration) {
149
+ // PREPARE ASSETS
150
+ var signature = checker.getSignatureFromDeclaration(declaration);
151
+ if (signature === undefined)
152
+ throw new Error("Error on ControllerAnalyzer._Analyze_function(): unable to get the ignature from the ".concat(controller.name, ".").concat(func.name, "()."));
153
+ var importDict = new HashMap_1.HashMap();
154
+ // EXPLORE CHILDREN TYPES
155
+ var parameters = func.parameters.map(function (param) { return _Analyze_parameter(checker, genericDict, importDict, controller, func.name, param, declaration.parameters[param.index]); });
156
+ var output = ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, checker.getReturnTypeOfSignature(signature));
157
+ var imports = importDict.toJSON().map(function (pair) { return [pair.first, pair.second.toJSON()]; });
158
+ // CONFIGURE PATH
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) {
166
+ if (path[0] !== "/")
167
+ path = "/" + path;
168
+ if (path[path.length - 1] === "/" && path !== "/")
169
+ path = path.substr(0, path.length - 1);
170
+ return path;
171
+ }
172
+ /* ---------------------------------------------------------
173
+ PARAMETER
174
+ --------------------------------------------------------- */
175
+ function _Analyze_parameter(checker, genericDict, importDict, controller, funcName, param, declaration) {
176
+ var symbol = checker.getSymbolAtLocation(declaration.name);
177
+ var type = checker.getTypeOfSymbolAtLocation(symbol, declaration);
178
+ var name = symbol.getEscapedName().toString();
179
+ // VALIDATE PARAMETERS
180
+ if ((param.category === "query" || param.category === "body") && param.field !== undefined)
181
+ throw new Error("Error on ".concat(controller.name, ".").concat(funcName, "(): parameter ").concat(name, " is specifying a field ").concat(param.field, " of the request ").concat(param.category, " message, however, Nestia does not support the field specialization for the request ").concat(param.category, " message. Erase the ").concat(controller.name, ".").concat(funcName, "()#").concat(name, " parameter and re-define a new decorator accepting full structured message."));
182
+ return {
183
+ name: name,
184
+ category: param.category,
185
+ field: param.field,
186
+ encrypted: param.encrypted,
187
+ type: ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, type)
188
+ };
189
+ }
190
+ })(ControllerAnalyzer = exports.ControllerAnalyzer || (exports.ControllerAnalyzer = {}));
191
+ //# sourceMappingURL=ControllerAnalyzer.js.map
@@ -0,0 +1,6 @@
1
+ import * as tsc from "typescript";
2
+ export declare namespace GenericAnalyzer {
3
+ type Dictionary = WeakMap<tsc.Type, tsc.Type>;
4
+ function analyze(checker: tsc.TypeChecker, classNode: tsc.ClassDeclaration): Dictionary;
5
+ }
6
+ //# sourceMappingURL=GenericAnalyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/GenericAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAElC,yBAAiB,eAAe,CAChC;IACI,KAAY,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAErD,SAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,GAAG,CAAC,gBAAgB,GAAG,UAAU,CAK7F;CAwCJ"}
@@ -0,0 +1,100 @@
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 __values = (this && this.__values) || function(o) {
26
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
27
+ if (m) return m.call(o);
28
+ if (o && typeof o.length === "number") return {
29
+ next: function () {
30
+ if (o && i >= o.length) o = void 0;
31
+ return { value: o && o[i++], done: !o };
32
+ }
33
+ };
34
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.GenericAnalyzer = void 0;
38
+ var tsc = __importStar(require("typescript"));
39
+ var GenericAnalyzer;
40
+ (function (GenericAnalyzer) {
41
+ function analyze(checker, classNode) {
42
+ var dict = new WeakMap();
43
+ explore(checker, dict, classNode);
44
+ return dict;
45
+ }
46
+ GenericAnalyzer.analyze = analyze;
47
+ function explore(checker, dict, classNode) {
48
+ var e_1, _a, e_2, _b;
49
+ if (classNode.heritageClauses === undefined)
50
+ return;
51
+ try {
52
+ for (var _c = __values(classNode.heritageClauses), _d = _c.next(); !_d.done; _d = _c.next()) {
53
+ var heritage = _d.value;
54
+ var _loop_1 = function (hType) {
55
+ // MUST BE CLASS
56
+ var expression = checker.getTypeAtLocation(hType.expression);
57
+ var superNode = expression.symbol.getDeclarations()[0];
58
+ if (!tsc.isClassDeclaration(superNode))
59
+ return "continue";
60
+ // SPECIFY GENERICS
61
+ var usages = if_undefined_array(hType.typeArguments);
62
+ var parameters = if_undefined_array(superNode.typeParameters);
63
+ parameters.forEach(function (param, index) {
64
+ var paramType = checker.getTypeAtLocation(param);
65
+ var usageType = (usages[index] !== undefined)
66
+ ? checker.getTypeAtLocation(usages[index])
67
+ : checker.getTypeAtLocation(param.default);
68
+ dict.set(paramType, usageType);
69
+ });
70
+ // RECUSRIVE EXPLORATION
71
+ explore(checker, dict, superNode);
72
+ };
73
+ try {
74
+ for (var _e = (e_2 = void 0, __values(heritage.types)), _f = _e.next(); !_f.done; _f = _e.next()) {
75
+ var hType = _f.value;
76
+ _loop_1(hType);
77
+ }
78
+ }
79
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
80
+ finally {
81
+ try {
82
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
83
+ }
84
+ finally { if (e_2) throw e_2.error; }
85
+ }
86
+ }
87
+ }
88
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
89
+ finally {
90
+ try {
91
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
92
+ }
93
+ finally { if (e_1) throw e_1.error; }
94
+ }
95
+ }
96
+ function if_undefined_array(array) {
97
+ return array !== undefined ? array : [];
98
+ }
99
+ })(GenericAnalyzer = exports.GenericAnalyzer || (exports.GenericAnalyzer = {}));
100
+ //# sourceMappingURL=GenericAnalyzer.js.map
@@ -0,0 +1,14 @@
1
+ import tsc from "typescript";
2
+ import { HashMap } from "tstl/container/HashMap";
3
+ import { HashSet } from "tstl/container/HashSet";
4
+ import { GenericAnalyzer } from "./GenericAnalyzer";
5
+ import { IType } from "../structures/IType";
6
+ export declare namespace ImportAnalyzer {
7
+ interface IOutput {
8
+ features: [string, string[]][];
9
+ alias: string;
10
+ }
11
+ type Dictionary = HashMap<string, HashSet<string>>;
12
+ function analyze(checker: tsc.TypeChecker, genericDict: GenericAnalyzer.Dictionary, importDict: Dictionary, type: tsc.Type): IType;
13
+ }
14
+ //# sourceMappingURL=ImportAnalyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImportAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ImportAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,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,KAAK,CAMX;CAoHJ"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ImportAnalyzer = void 0;
7
+ var typescript_1 = __importDefault(require("typescript"));
8
+ var HashSet_1 = require("tstl/container/HashSet");
9
+ var ImportAnalyzer;
10
+ (function (ImportAnalyzer) {
11
+ function analyze(checker, genericDict, importDict, type) {
12
+ return {
13
+ metadata: get_type(checker, type),
14
+ escapedText: explore_escaped_name(checker, genericDict, importDict, type)
15
+ };
16
+ }
17
+ ImportAnalyzer.analyze = analyze;
18
+ /* ---------------------------------------------------------
19
+ TYPE
20
+ --------------------------------------------------------- */
21
+ function get_type(checker, type) {
22
+ var symbol = type.getSymbol() || type.aliasSymbol;
23
+ return symbol && get_name(symbol) === "Promise"
24
+ ? escape_promise(checker, type)
25
+ : type;
26
+ }
27
+ function escape_promise(checker, type) {
28
+ var generic = checker.getTypeArguments(type);
29
+ if (generic.length !== 1)
30
+ throw new Error("Error on ImportAnalyzer.analyze(): invalid promise type.");
31
+ return generic[0];
32
+ }
33
+ function get_name(symbol) {
34
+ return explore_name(symbol.escapedName.toString(), symbol.getDeclarations()[0].parent);
35
+ }
36
+ /* ---------------------------------------------------------
37
+ ESCAPED TEXT WITH IMPORT STATEMENTS
38
+ --------------------------------------------------------- */
39
+ function explore_escaped_name(checker, genericDict, importDict, type) {
40
+ //----
41
+ // CONDITIONAL BRANCHES
42
+ //----
43
+ // DECOMPOSE GENERIC ARGUMENT
44
+ while (genericDict.has(type) === true)
45
+ type = genericDict.get(type);
46
+ // PRIMITIVE
47
+ var symbol = type.getSymbol() || type.aliasSymbol;
48
+ if (symbol === undefined)
49
+ return checker.typeToString(type, undefined, undefined);
50
+ // UNION OR INTERSECT
51
+ else if (type.aliasSymbol === undefined && type.isUnionOrIntersection()) {
52
+ var joiner = type.isIntersection() ? " & " : " | ";
53
+ return type.types.map(function (child) { return explore_escaped_name(checker, genericDict, importDict, child); }).join(joiner);
54
+ }
55
+ //----
56
+ // SPECIALIZATION
57
+ //----
58
+ var name = get_name(symbol);
59
+ var sourceFile = symbol.declarations[0].getSourceFile();
60
+ if (sourceFile.fileName.indexOf("typescript/lib") === -1) {
61
+ var set = importDict.take(sourceFile.fileName, function () { return new HashSet_1.HashSet(); });
62
+ set.insert(name.split(".")[0]);
63
+ }
64
+ // CHECK GENERIC
65
+ var generic = checker.getTypeArguments(type);
66
+ if (generic.length)
67
+ return name === "Promise"
68
+ ? explore_escaped_name(checker, genericDict, importDict, generic[0])
69
+ : "".concat(name, "<").concat(generic.map(function (child) { return explore_escaped_name(checker, genericDict, importDict, child); }).join(", "), ">");
70
+ else
71
+ return name;
72
+ }
73
+ function explore_name(name, decl) {
74
+ return typescript_1.default.isModuleBlock(decl)
75
+ ? explore_name("".concat(decl.parent.name.getText(), ".").concat(name), decl.parent.parent)
76
+ : name;
77
+ }
78
+ })(ImportAnalyzer = exports.ImportAnalyzer || (exports.ImportAnalyzer = {}));
79
+ //# sourceMappingURL=ImportAnalyzer.js.map
@@ -0,0 +1,5 @@
1
+ import { IController } from "../structures/IController";
2
+ export declare namespace ReflectAnalyzer {
3
+ function analyze(unique: WeakSet<any>, file: string): Promise<IController[]>;
4
+ }
5
+ //# sourceMappingURL=ReflectAnalyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReflectAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ReflectAnalyzer.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAQxD,yBAAiB,eAAe,CAChC;IACI,SAAsB,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAiBxF;CAsMJ"}