node-dependency-injection 3.0.0-beta.6 → 3.0.1

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 (120) hide show
  1. package/.eslintrc +16 -0
  2. package/.travis.yml +2 -5
  3. package/CHANGELOG-3.md +2 -0
  4. package/CONTRIBUTING.md +2 -2
  5. package/README.md +4 -4
  6. package/UPGRADE-3.0.md +2 -1
  7. package/dist/bin/Services/File/BaseAdapter.js +3 -50
  8. package/dist/bin/Services/File/FileManager.js +3 -49
  9. package/dist/bin/Services/File/JsAdapter.js +5 -62
  10. package/dist/bin/Services/File/JsonAdapter.js +5 -60
  11. package/dist/bin/Services/File/YamlAdapter.js +5 -65
  12. package/dist/bin/ndi-config:check.js +1 -55
  13. package/dist/bin/ndi-config:create.js +1 -40
  14. package/dist/bin/ndi-container:service.js +1 -131
  15. package/dist/bin/ndi.js +1 -9
  16. package/dist/lib/Autowire.js +74 -793
  17. package/dist/lib/AutowireIdentifier.js +7 -0
  18. package/dist/lib/Compiler.js +8 -209
  19. package/dist/lib/CompilerPass/DecoratePass.js +11 -180
  20. package/dist/lib/CompilerPass/OptimizePass.js +3 -82
  21. package/dist/lib/CompilerPass/RemovePass.js +3 -79
  22. package/dist/lib/CompilerPass/index.js +12 -175
  23. package/dist/lib/ContainerBuilder.js +84 -493
  24. package/dist/lib/Definition.js +77 -368
  25. package/dist/lib/Dump/Dumper.js +1 -19
  26. package/dist/lib/Dump/JsDumper.js +1 -77
  27. package/dist/lib/Dump/JsonDumper.js +1 -75
  28. package/dist/lib/Dump/YamlDumper.js +1 -77
  29. package/dist/lib/Exception/AbstractServiceException.js +2 -46
  30. package/dist/lib/Exception/AttributesMapException.js +1 -44
  31. package/dist/lib/Exception/ConfigurationFileNotFoundException.js +2 -46
  32. package/dist/lib/Exception/ContainerDefaultDirMustBeSet.js +3 -0
  33. package/dist/lib/Exception/DefinitionNotFoundException.js +2 -46
  34. package/dist/lib/Exception/FrozenContainerException.js +1 -44
  35. package/dist/lib/Exception/LoadMethodNotFoundException.js +2 -46
  36. package/dist/lib/Exception/LoggerWarnMethodNotFoundException.js +1 -44
  37. package/dist/lib/Exception/MethodCallEmptyException.js +1 -44
  38. package/dist/lib/Exception/MethodCallNotFoundException.js +2 -46
  39. package/dist/lib/Exception/NotAbstractServiceException.js +2 -46
  40. package/dist/lib/Exception/PrivateServiceException.js +2 -46
  41. package/dist/lib/Exception/ProcessMethodNotFoundException.js +2 -46
  42. package/dist/lib/Exception/RootDirectoryMustBeAbsolute.js +1 -0
  43. package/dist/lib/Exception/RootDirectoryNotFound.js +1 -0
  44. package/dist/lib/Exception/ServiceCircularReferenceException.js +1 -44
  45. package/dist/lib/Exception/ServiceFileNotAbsolute.js +1 -44
  46. package/dist/lib/Exception/ServiceFileNotFoundException.js +2 -46
  47. package/dist/lib/Exception/ServiceFileNotLoadedException.js +2 -46
  48. package/dist/lib/Exception/ServiceFileNotValidExtension.js +1 -44
  49. package/dist/lib/Exception/ServiceNotFoundException.js +2 -47
  50. package/dist/lib/Exception/UnableToGetInstanceFromId.js +2 -49
  51. package/dist/lib/Exception/WrongCompilerPassTypeException.js +2 -46
  52. package/dist/lib/Exception/WrongDefinitionException.js +1 -44
  53. package/dist/lib/InstanceManager.js +54 -406
  54. package/dist/lib/Loader/FileLoader.js +72 -624
  55. package/dist/lib/Loader/JsFileLoader.js +3 -101
  56. package/dist/lib/Loader/JsonFileLoader.js +1 -39
  57. package/dist/lib/Loader/YamlFileLoader.js +3 -133
  58. package/dist/lib/PackageReference.js +3 -35
  59. package/dist/lib/PassConfig.js +14 -78
  60. package/dist/lib/Reference.js +5 -46
  61. package/dist/lib/ServiceFile.js +20 -210
  62. package/dist/lib/TagReference.js +3 -35
  63. package/dist/lib/index.js +1 -87
  64. package/dist/lib/types/index.d.ts +13 -5
  65. package/dist/lib/types/tests.ts +9 -2
  66. package/package.json +11 -3
  67. package/coverage/lcov-report/base.css +0 -224
  68. package/coverage/lcov-report/bin/Services/File/BaseAdapter.js.html +0 -158
  69. package/coverage/lcov-report/bin/Services/File/FileManager.js.html +0 -176
  70. package/coverage/lcov-report/bin/Services/File/JsAdapter.js.html +0 -140
  71. package/coverage/lcov-report/bin/Services/File/JsonAdapter.js.html +0 -131
  72. package/coverage/lcov-report/bin/Services/File/YamlAdapter.js.html +0 -155
  73. package/coverage/lcov-report/bin/Services/File/index.html +0 -171
  74. package/coverage/lcov-report/block-navigation.js +0 -79
  75. package/coverage/lcov-report/favicon.png +0 -0
  76. package/coverage/lcov-report/index.html +0 -171
  77. package/coverage/lcov-report/lib/Autowire.js.html +0 -506
  78. package/coverage/lcov-report/lib/Compiler.js.html +0 -239
  79. package/coverage/lcov-report/lib/CompilerPass/DecoratePass.js.html +0 -248
  80. package/coverage/lcov-report/lib/CompilerPass/OptimizePass.js.html +0 -128
  81. package/coverage/lcov-report/lib/CompilerPass/RemovePass.js.html +0 -116
  82. package/coverage/lcov-report/lib/CompilerPass/index.html +0 -156
  83. package/coverage/lcov-report/lib/CompilerPass/index.js.html +0 -326
  84. package/coverage/lcov-report/lib/ContainerBuilder.js.html +0 -1115
  85. package/coverage/lcov-report/lib/Definition.js.html +0 -962
  86. package/coverage/lcov-report/lib/Exception/AbstractServiceException.js.html +0 -110
  87. package/coverage/lcov-report/lib/Exception/AttributesMapException.js.html +0 -101
  88. package/coverage/lcov-report/lib/Exception/ConfigurationFileNotFoundException.js.html +0 -110
  89. package/coverage/lcov-report/lib/Exception/DefinitionNotFoundException.js.html +0 -110
  90. package/coverage/lcov-report/lib/Exception/FrozenContainerException.js.html +0 -101
  91. package/coverage/lcov-report/lib/Exception/LoadMethodNotFoundException.js.html +0 -110
  92. package/coverage/lcov-report/lib/Exception/LoggerWarnMethodNotFoundException.js.html +0 -101
  93. package/coverage/lcov-report/lib/Exception/MethodCallEmptyException.js.html +0 -101
  94. package/coverage/lcov-report/lib/Exception/MethodCallNotFoundException.js.html +0 -110
  95. package/coverage/lcov-report/lib/Exception/NotAbstractServiceException.js.html +0 -110
  96. package/coverage/lcov-report/lib/Exception/PrivateServiceException.js.html +0 -110
  97. package/coverage/lcov-report/lib/Exception/ProcessMethodNotFoundException.js.html +0 -110
  98. package/coverage/lcov-report/lib/Exception/ServiceCircularReferenceException.js.html +0 -101
  99. package/coverage/lcov-report/lib/Exception/ServiceFileNotFoundException.js.html +0 -110
  100. package/coverage/lcov-report/lib/Exception/ServiceFileNotLoadedException.js.html +0 -110
  101. package/coverage/lcov-report/lib/Exception/ServiceNotFoundException.js.html +0 -113
  102. package/coverage/lcov-report/lib/Exception/WrongCompilerPassTypeException.js.html +0 -110
  103. package/coverage/lcov-report/lib/Exception/WrongDefinitionException.js.html +0 -101
  104. package/coverage/lcov-report/lib/Exception/index.html +0 -366
  105. package/coverage/lcov-report/lib/InstanceManager.js.html +0 -839
  106. package/coverage/lcov-report/lib/Loader/FileLoader.js.html +0 -1034
  107. package/coverage/lcov-report/lib/Loader/JsFileLoader.js.html +0 -155
  108. package/coverage/lcov-report/lib/Loader/JsonFileLoader.js.html +0 -98
  109. package/coverage/lcov-report/lib/Loader/YamlFileLoader.js.html +0 -188
  110. package/coverage/lcov-report/lib/Loader/index.html +0 -156
  111. package/coverage/lcov-report/lib/PackageReference.js.html +0 -131
  112. package/coverage/lcov-report/lib/PassConfig.js.html +0 -230
  113. package/coverage/lcov-report/lib/Reference.js.html +0 -158
  114. package/coverage/lcov-report/lib/TagReference.js.html +0 -131
  115. package/coverage/lcov-report/lib/index.html +0 -231
  116. package/coverage/lcov-report/prettify.css +0 -1
  117. package/coverage/lcov-report/prettify.js +0 -2
  118. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  119. package/coverage/lcov-report/sorter.js +0 -170
  120. package/coverage/lcov.info +0 -1516
@@ -1,794 +1,75 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _path = _interopRequireDefault(require("path"));
19
-
20
- var _fs = _interopRequireDefault(require("fs"));
21
-
22
- var _json = _interopRequireDefault(require("json5"));
23
-
24
- var _typescriptEstree = require("@typescript-eslint/typescript-estree");
25
-
26
- var _Definition = _interopRequireDefault(require("./Definition"));
27
-
28
- var _Reference = _interopRequireDefault(require("./Reference"));
29
-
30
- var _ServiceFile = _interopRequireDefault(require("./ServiceFile"));
31
-
32
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
33
-
34
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
35
-
36
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37
-
38
- var Autowire = /*#__PURE__*/function () {
39
- function Autowire(container) {
40
- var tsConfigFullPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
41
- (0, _classCallCheck2["default"])(this, Autowire);
42
- this._interfaceImplementation = new Map();
43
- this._rootDirectory = container.defaultDir;
44
- this._container = container;
45
- this._excludedFolders = [];
46
- this._dumpServiceFile = null;
47
-
48
- try {
49
- this._tsConfigFullPath = tsConfigFullPath || _path["default"].join(process.cwd(), 'tsconfig.json');
50
- this._tsConfigPaths = _json["default"].parse(_fs["default"].readFileSync(this._tsConfigFullPath, 'utf-8')).compilerOptions.paths;
51
- } catch (e) {
52
- this._tsConfigPaths = null;
53
- }
54
- }
55
- /**
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _path=_interopRequireDefault(require("path"));var _fs=_interopRequireDefault(require("fs"));var _json=_interopRequireDefault(require("json5"));var _typescriptEstree=require("@typescript-eslint/typescript-estree");var _Definition=_interopRequireDefault(require("./Definition"));var _Reference=_interopRequireDefault(require("./Reference"));var _ServiceFile=_interopRequireDefault(require("./ServiceFile"));var _AutowireIdentifier=_interopRequireDefault(require("./AutowireIdentifier"));var _ContainerDefaultDirMustBeSet=_interopRequireDefault(require("./Exception/ContainerDefaultDirMustBeSet"));function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}var Autowire=/*#__PURE__*/function(){/**
2
+ * @param {ContainerBuilder} container
3
+ * @param {string} tsConfigFullPath
4
+ */function Autowire(container){var tsConfigFullPath=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;(0,_classCallCheck2["default"])(this,Autowire);this._ensureContainerIsValidForAutowire(container);this._rootDirectory=container.defaultDir;this._container=container;this._excludedFolders=[];this._serviceFile=null;try{this._tsConfigFullPath=tsConfigFullPath||_path["default"].join(process.cwd(),'tsconfig.json');this._tsConfigPaths=_json["default"].parse(_fs["default"].readFileSync(this._tsConfigFullPath,'utf-8')).compilerOptions.paths;}catch(e){this._tsConfigPaths=null;}}(0,_createClass2["default"])(Autowire,[{key:"_ensureContainerIsValidForAutowire",value:function _ensureContainerIsValidForAutowire(container){if(container.defaultDir===null){throw new _ContainerDefaultDirMustBeSet["default"]();}}/**
56
5
  * @return {ContainerBuilder}
57
- */
58
-
59
-
60
- (0, _createClass2["default"])(Autowire, [{
61
- key: "container",
62
- get: function get() {
63
- return this._container;
64
- }
65
- /**
66
- * @private
67
- */
68
-
69
- }, {
70
- key: "_walk",
71
- value:
72
- /*#__PURE__*/
73
- _regenerator["default"].mark(function _walk(dir) {
74
- var files, _iterator, _step, file, filePath;
75
-
76
- return _regenerator["default"].wrap(function _walk$(_context) {
77
- while (1) {
78
- switch (_context.prev = _context.next) {
79
- case 0:
80
- files = _fs["default"].readdirSync(dir, {
81
- withFileTypes: true
82
- });
83
- _iterator = _createForOfIteratorHelper(files);
84
- _context.prev = 2;
85
-
86
- _iterator.s();
87
-
88
- case 4:
89
- if ((_step = _iterator.n()).done) {
90
- _context.next = 20;
91
- break;
92
- }
93
-
94
- file = _step.value;
95
-
96
- if (!file.isDirectory()) {
97
- _context.next = 9;
98
- break;
99
- }
100
-
101
- return _context.delegateYield(this._walk(_path["default"].join(dir, file.name)), "t0", 8);
102
-
103
- case 8:
104
- return _context.abrupt("continue", 18);
105
-
106
- case 9:
107
- filePath = _path["default"].join(dir, file.name);
108
- _context.prev = 10;
109
-
110
- this._ensureFileIsNotExcluded(filePath);
111
-
112
- _context.next = 14;
113
- return filePath;
114
-
115
- case 14:
116
- _context.next = 18;
117
- break;
118
-
119
- case 16:
120
- _context.prev = 16;
121
- _context.t1 = _context["catch"](10);
122
-
123
- case 18:
124
- _context.next = 4;
125
- break;
126
-
127
- case 20:
128
- _context.next = 25;
129
- break;
130
-
131
- case 22:
132
- _context.prev = 22;
133
- _context.t2 = _context["catch"](2);
134
-
135
- _iterator.e(_context.t2);
136
-
137
- case 25:
138
- _context.prev = 25;
139
-
140
- _iterator.f();
141
-
142
- return _context.finish(25);
143
-
144
- case 28:
145
- case "end":
146
- return _context.stop();
147
- }
148
- }
149
- }, _walk, this, [[2, 22, 25, 28], [10, 16]]);
150
- })
151
- /**
152
- * @private
153
- * @param {string} filePath
154
- * @returns {void}
155
- */
156
-
157
- }, {
158
- key: "_ensureFileIsNotExcluded",
159
- value: function _ensureFileIsNotExcluded(filePath) {
160
- this._excludedFolders.forEach(function (excludedFolder) {
161
- if (filePath.includes(excludedFolder)) {
162
- throw new Error('Excluded Folder!');
163
- }
164
- });
165
- }
166
- /**
167
- * @param {string} path
168
- */
169
-
170
- }, {
171
- key: "addExclude",
172
- value: function addExclude(relativePath) {
173
- var fullPathToExclude = _path["default"].join(this._rootDirectory, relativePath);
174
-
175
- this._excludedFolders.push(fullPathToExclude);
176
- }
177
- /**
178
- * @private
179
- * @param {string} path
180
- * @param {string} type
181
- * @param {string} extension
182
- * @returns {Promise}
183
- */
184
-
185
- }, {
186
- key: "_getServiceIdFromPath",
187
- value: function () {
188
- var _getServiceIdFromPath2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(path, type) {
189
- var extension,
190
- _args2 = arguments;
191
- return _regenerator["default"].wrap(function _callee$(_context2) {
192
- while (1) {
193
- switch (_context2.prev = _context2.next) {
194
- case 0:
195
- extension = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : '.ts';
196
- return _context2.abrupt("return", path.replace(/\//g, '__').replace(extension, '').replace('@', '__').concat("__".concat(type)));
197
-
198
- case 2:
199
- case "end":
200
- return _context2.stop();
201
- }
202
- }
203
- }, _callee);
204
- }));
205
-
206
- function _getServiceIdFromPath(_x, _x2) {
207
- return _getServiceIdFromPath2.apply(this, arguments);
208
- }
209
-
210
- return _getServiceIdFromPath;
211
- }()
212
- /**
213
- * @return {Promise}
214
- */
215
-
216
- }, {
217
- key: "process",
218
- value: function () {
219
- var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
220
- var promises, _iterator2, _step2, filePath;
221
-
222
- return _regenerator["default"].wrap(function _callee2$(_context3) {
223
- while (1) {
224
- switch (_context3.prev = _context3.next) {
225
- case 0:
226
- promises = [];
227
- _iterator2 = _createForOfIteratorHelper(this._walk(this._rootDirectory));
228
-
229
- try {
230
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
231
- filePath = _step2.value;
232
- promises.push(this._executeFilePath(filePath));
233
- }
234
- } catch (err) {
235
- _iterator2.e(err);
236
- } finally {
237
- _iterator2.f();
238
- }
239
-
240
- _context3.next = 5;
241
- return Promise.all(promises);
242
-
243
- case 5:
244
- if (!(this._dumpServiceFile instanceof _ServiceFile["default"])) {
245
- _context3.next = 8;
246
- break;
247
- }
248
-
249
- _context3.next = 8;
250
- return this._dumpServiceFile._generateFromContainer(this._container);
251
-
252
- case 8:
253
- case "end":
254
- return _context3.stop();
255
- }
256
- }
257
- }, _callee2, this);
258
- }));
259
-
260
- function process() {
261
- return _process.apply(this, arguments);
262
- }
263
-
264
- return process;
265
- }()
266
- /**
267
- * @param {string} filePath
268
- * @returns {Promise}
269
- * @private
270
- */
271
-
272
- }, {
273
- key: "_executeFilePath",
274
- value: function () {
275
- var _executeFilePath2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(filePath) {
276
- var parsedFile, _yield$this$_getClass, classDeclaration, body, Class, definition, serviceId;
277
-
278
- return _regenerator["default"].wrap(function _callee3$(_context4) {
279
- while (1) {
280
- switch (_context4.prev = _context4.next) {
281
- case 0:
282
- parsedFile = _path["default"].parse(filePath);
283
-
284
- if (!(parsedFile.ext !== '.ts')) {
285
- _context4.next = 3;
286
- break;
287
- }
288
-
289
- return _context4.abrupt("return");
290
-
291
- case 3:
292
- _context4.next = 5;
293
- return this._getClassDeclaration(filePath);
294
-
295
- case 5:
296
- _yield$this$_getClass = _context4.sent;
297
- classDeclaration = _yield$this$_getClass.classDeclaration;
298
- body = _yield$this$_getClass.body;
299
-
300
- if (classDeclaration) {
301
- _context4.next = 10;
302
- break;
303
- }
304
-
305
- return _context4.abrupt("return");
306
-
307
- case 10:
308
- Class = require(filePath)["default"];
309
-
310
- if (Class) {
311
- _context4.next = 13;
312
- break;
313
- }
314
-
315
- return _context4.abrupt("return");
316
-
317
- case 13:
318
- _context4.next = 15;
319
- return this._getDefinition(classDeclaration, body, parsedFile, Class);
320
-
321
- case 15:
322
- definition = _context4.sent;
323
-
324
- if (definition) {
325
- _context4.next = 18;
326
- break;
327
- }
328
-
329
- return _context4.abrupt("return");
330
-
331
- case 18:
332
- _context4.next = 20;
333
- return this._getServiceIdFromPath(filePath, Class.name);
334
-
335
- case 20:
336
- serviceId = _context4.sent;
337
- this.container.setDefinition(serviceId, definition);
338
- _context4.next = 24;
339
- return this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
340
-
341
- case 24:
342
- case "end":
343
- return _context4.stop();
344
- }
345
- }
346
- }, _callee3, this);
347
- }));
348
-
349
- function _executeFilePath(_x3) {
350
- return _executeFilePath2.apply(this, arguments);
351
- }
352
-
353
- return _executeFilePath;
354
- }()
355
- /**
356
- *
357
- * @param {string} filePath
358
- * @returns {Promise}
359
- * @private
360
- */
361
-
362
- }, {
363
- key: "_getClassDeclaration",
364
- value: function () {
365
- var _getClassDeclaration2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(filePath) {
366
- var sourceCode, body, classDeclaration;
367
- return _regenerator["default"].wrap(function _callee4$(_context5) {
368
- while (1) {
369
- switch (_context5.prev = _context5.next) {
370
- case 0:
371
- sourceCode = _fs["default"].readFileSync(filePath, 'utf8');
372
- body = (0, _typescriptEstree.parse)(sourceCode).body;
373
- classDeclaration = body.find(function (declaration) {
374
- return declaration.type === 'ExportDefaultDeclaration';
375
- });
376
- return _context5.abrupt("return", {
377
- classDeclaration: classDeclaration,
378
- body: body
379
- });
380
-
381
- case 4:
382
- case "end":
383
- return _context5.stop();
384
- }
385
- }
386
- }, _callee4);
387
- }));
388
-
389
- function _getClassDeclaration(_x4) {
390
- return _getClassDeclaration2.apply(this, arguments);
391
- }
392
-
393
- return _getClassDeclaration;
394
- }()
395
- /**
396
- *
397
- * @param {object} classDeclaration
398
- * @param {string} body
399
- * @param {any} parsedFile
400
- * @param {any} ServiceClass
401
- * @returns
402
- * @private
403
- */
404
-
405
- }, {
406
- key: "_getDefinition",
407
- value: function () {
408
- var _getDefinition2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(classDeclaration, body, parsedFile, ServiceClass) {
409
- var definition, constructorParams, _iterator3, _step3, parameterDeclaration, typeNameForArgument, argumentId;
410
-
411
- return _regenerator["default"].wrap(function _callee5$(_context6) {
412
- while (1) {
413
- switch (_context6.prev = _context6.next) {
414
- case 0:
415
- _context6.prev = 0;
416
- definition = new _Definition["default"](ServiceClass);
417
- _context6.next = 4;
418
- return this._getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile);
419
-
420
- case 4:
421
- constructorParams = _context6.sent;
422
- _iterator3 = _createForOfIteratorHelper(constructorParams);
423
- _context6.prev = 6;
424
-
425
- _iterator3.s();
426
-
427
- case 8:
428
- if ((_step3 = _iterator3.n()).done) {
429
- _context6.next = 19;
430
- break;
431
- }
432
-
433
- parameterDeclaration = _step3.value;
434
- typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
435
- _context6.next = 13;
436
- return this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
437
-
438
- case 13:
439
- argumentId = _context6.sent;
440
-
441
- if (argumentId) {
442
- _context6.next = 16;
443
- break;
444
- }
445
-
446
- return _context6.abrupt("continue", 17);
447
-
448
- case 16:
449
- definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
450
-
451
- case 17:
452
- _context6.next = 8;
453
- break;
454
-
455
- case 19:
456
- _context6.next = 24;
457
- break;
458
-
459
- case 21:
460
- _context6.prev = 21;
461
- _context6.t0 = _context6["catch"](6);
462
-
463
- _iterator3.e(_context6.t0);
464
-
465
- case 24:
466
- _context6.prev = 24;
467
-
468
- _iterator3.f();
469
-
470
- return _context6.finish(24);
471
-
472
- case 27:
473
- return _context6.abrupt("return", definition);
474
-
475
- case 30:
476
- _context6.prev = 30;
477
- _context6.t1 = _context6["catch"](0);
478
-
479
- case 32:
480
- case "end":
481
- return _context6.stop();
482
- }
483
- }
484
- }, _callee5, this, [[0, 30], [6, 21, 24, 27]]);
485
- }));
486
-
487
- function _getDefinition(_x5, _x6, _x7, _x8) {
488
- return _getDefinition2.apply(this, arguments);
489
- }
490
-
491
- return _getDefinition;
492
- }()
493
- /**
494
- * @private
495
- * @param {Definition} definition
496
- * @param {object} classDeclaration
497
- * @param {any} body
498
- * @param {any} parsedFile
499
- * @returns
500
- */
501
-
502
- }, {
503
- key: "_getConstructorParamsByDefinition",
504
- value: function () {
505
- var _getConstructorParamsByDefinition2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(definition, classDeclaration, body, parsedFile) {
506
- var constructorDeclaration, constructorParams;
507
- return _regenerator["default"].wrap(function _callee6$(_context7) {
508
- while (1) {
509
- switch (_context7.prev = _context7.next) {
510
- case 0:
511
- constructorDeclaration = classDeclaration.declaration.body.body.find(function (method) {
512
- return method.key.name === 'constructor';
513
- });
514
-
515
- if (classDeclaration.declaration["abstract"]) {
516
- definition["abstract"] = true;
517
- }
518
-
519
- _context7.next = 4;
520
- return this._parentDefinition(classDeclaration, body, parsedFile, definition);
521
-
522
- case 4:
523
- constructorParams = constructorDeclaration ? constructorDeclaration.value.params : [];
524
- return _context7.abrupt("return", constructorParams);
525
-
526
- case 6:
527
- case "end":
528
- return _context7.stop();
529
- }
530
- }
531
- }, _callee6, this);
532
- }));
533
-
534
- function _getConstructorParamsByDefinition(_x9, _x10, _x11, _x12) {
535
- return _getConstructorParamsByDefinition2.apply(this, arguments);
536
- }
537
-
538
- return _getConstructorParamsByDefinition;
539
- }()
540
- /**
541
- * @private
542
- * @param {object} classDeclaration
543
- * @param {any} body
544
- * @param {any} parsedFile
545
- * @param {Definition} definition
546
- */
547
-
548
- }, {
549
- key: "_parentDefinition",
550
- value: function () {
551
- var _parentDefinition2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(classDeclaration, body, parsedFile, definition) {
552
- var typeParent, parentId;
553
- return _regenerator["default"].wrap(function _callee7$(_context8) {
554
- while (1) {
555
- switch (_context8.prev = _context8.next) {
556
- case 0:
557
- if (!classDeclaration.declaration.superClass) {
558
- _context8.next = 6;
559
- break;
560
- }
561
-
562
- typeParent = classDeclaration.declaration.superClass.name;
563
- _context8.next = 4;
564
- return this._getIdentifierFromImports(typeParent, body, parsedFile);
565
-
566
- case 4:
567
- parentId = _context8.sent;
568
-
569
- if (parentId) {
570
- definition.parent = parentId;
571
- }
572
-
573
- case 6:
574
- case "end":
575
- return _context8.stop();
576
- }
577
- }
578
- }, _callee7, this);
579
- }));
580
-
581
- function _parentDefinition(_x13, _x14, _x15, _x16) {
582
- return _parentDefinition2.apply(this, arguments);
583
- }
584
-
585
- return _parentDefinition;
586
- }()
587
- /**
588
- * @private
589
- * @param {any} classDeclaration
590
- * @param {any} body
591
- * @param {any} parsedFile
592
- * @param {string} serviceId
593
- */
594
-
595
- }, {
596
- key: "_interfaceImplementations",
597
- value: function () {
598
- var _interfaceImplementations2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(classDeclaration, body, parsedFile, serviceId) {
599
- var _classDeclaration$dec;
600
-
601
- var implementations, _iterator4, _step4, implement, interfaceType, aliasId;
602
-
603
- return _regenerator["default"].wrap(function _callee8$(_context9) {
604
- while (1) {
605
- switch (_context9.prev = _context9.next) {
606
- case 0:
607
- implementations = (_classDeclaration$dec = classDeclaration.declaration["implements"]) !== null && _classDeclaration$dec !== void 0 ? _classDeclaration$dec : [];
608
- _iterator4 = _createForOfIteratorHelper(implementations);
609
- _context9.prev = 2;
610
-
611
- _iterator4.s();
612
-
613
- case 4:
614
- if ((_step4 = _iterator4.n()).done) {
615
- _context9.next = 15;
616
- break;
617
- }
618
-
619
- implement = _step4.value;
620
- interfaceType = implement.expression.name;
621
- _context9.next = 9;
622
- return this._getIdentifierFromImports(interfaceType, body, parsedFile);
623
-
624
- case 9:
625
- aliasId = _context9.sent;
626
-
627
- if (!(!aliasId || this.container.hasAlias(aliasId))) {
628
- _context9.next = 12;
629
- break;
630
- }
631
-
632
- return _context9.abrupt("continue", 13);
633
-
634
- case 12:
635
- this.container.setAlias(aliasId, serviceId);
636
-
637
- case 13:
638
- _context9.next = 4;
639
- break;
640
-
641
- case 15:
642
- _context9.next = 20;
643
- break;
644
-
645
- case 17:
646
- _context9.prev = 17;
647
- _context9.t0 = _context9["catch"](2);
648
-
649
- _iterator4.e(_context9.t0);
650
-
651
- case 20:
652
- _context9.prev = 20;
653
-
654
- _iterator4.f();
655
-
656
- return _context9.finish(20);
657
-
658
- case 23:
659
- case "end":
660
- return _context9.stop();
661
- }
662
- }
663
- }, _callee8, this, [[2, 17, 20, 23]]);
664
- }));
665
-
666
- function _interfaceImplementations(_x17, _x18, _x19, _x20) {
667
- return _interfaceImplementations2.apply(this, arguments);
668
- }
669
-
670
- return _interfaceImplementations;
671
- }()
672
- /**
673
- * @private
674
- * @param {string} type
675
- * @param {any} body
676
- * @param {anty} parsedFile
677
- * @returns {Promise}
678
- */
679
-
680
- }, {
681
- key: "_getIdentifierFromImports",
682
- value: function () {
683
- var _getIdentifierFromImports2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(type, body, parsedFile) {
684
- var _this$_tsConfigPaths, rootDir, relativeImportForImplement, configPaths, pathConfig, tsConfigPath, tsRelativePath, parsedTsConfigPath, absolutePathImportForImplement;
685
-
686
- return _regenerator["default"].wrap(function _callee9$(_context10) {
687
- while (1) {
688
- switch (_context10.prev = _context10.next) {
689
- case 0:
690
- _context10.prev = 0;
691
- rootDir = parsedFile.dir;
692
- _context10.next = 4;
693
- return this._getRelativeImport(body, type);
694
-
695
- case 4:
696
- relativeImportForImplement = _context10.sent;
697
- configPaths = (_this$_tsConfigPaths = this._tsConfigPaths) !== null && _this$_tsConfigPaths !== void 0 ? _this$_tsConfigPaths : [];
698
- _context10.t0 = _regenerator["default"].keys(configPaths);
699
-
700
- case 7:
701
- if ((_context10.t1 = _context10.t0()).done) {
702
- _context10.next = 18;
703
- break;
704
- }
705
-
706
- pathConfig = _context10.t1.value;
707
- tsConfigPath = pathConfig.replace(/\*/g, '');
708
- tsRelativePath = this._tsConfigPaths[pathConfig][0].replace(/\*/g, '');
709
-
710
- if (relativeImportForImplement.includes(tsConfigPath)) {
711
- _context10.next = 13;
712
- break;
713
- }
714
-
715
- return _context10.abrupt("continue", 7);
716
-
717
- case 13:
718
- relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
719
- parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
720
- rootDir = parsedTsConfigPath.dir;
721
- _context10.next = 7;
722
- break;
723
-
724
- case 18:
725
- absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
726
- return _context10.abrupt("return", this._getServiceIdFromPath(absolutePathImportForImplement, type));
727
-
728
- case 22:
729
- _context10.prev = 22;
730
- _context10.t2 = _context10["catch"](0);
731
-
732
- case 24:
733
- case "end":
734
- return _context10.stop();
735
- }
736
- }
737
- }, _callee9, this, [[0, 22]]);
738
- }));
739
-
740
- function _getIdentifierFromImports(_x21, _x22, _x23) {
741
- return _getIdentifierFromImports2.apply(this, arguments);
742
- }
743
-
744
- return _getIdentifierFromImports;
745
- }()
746
- /**
747
- * @private
748
- * @param {any} body
749
- * @param {string} type
750
- * @returns {Promise}
751
- */
752
-
753
- }, {
754
- key: "_getRelativeImport",
755
- value: function () {
756
- var _getRelativeImport2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(body, type) {
757
- return _regenerator["default"].wrap(function _callee10$(_context11) {
758
- while (1) {
759
- switch (_context11.prev = _context11.next) {
760
- case 0:
761
- return _context11.abrupt("return", body.find(function (declaration) {
762
- if (declaration.specifiers) {
763
- return declaration.specifiers.find(function (specifier) {
764
- return specifier.local.name === type;
765
- });
766
- }
767
-
768
- return null;
769
- }).source.value);
770
-
771
- case 1:
772
- case "end":
773
- return _context11.stop();
774
- }
775
- }
776
- }, _callee10);
777
- }));
778
-
779
- function _getRelativeImport(_x24, _x25) {
780
- return _getRelativeImport2.apply(this, arguments);
781
- }
782
-
783
- return _getRelativeImport;
784
- }()
785
- }, {
786
- key: "enableDump",
787
- value: function enableDump(servicesDumpPath) {
788
- this._dumpServiceFile = new _ServiceFile["default"](servicesDumpPath);
789
- }
790
- }]);
791
- return Autowire;
792
- }();
793
-
794
- exports["default"] = Autowire;
6
+ */},{key:"container",get:function get(){return this._container;}/**
7
+ * @private
8
+ * @param {string}
9
+ * @return {Iterable}
10
+ */},{key:"_walk",value:/*#__PURE__*/_regenerator["default"].mark(function _walk(dir){var files,_iterator,_step,file,filePath;return _regenerator["default"].wrap(function _walk$(_context){while(1){switch(_context.prev=_context.next){case 0:files=_fs["default"].readdirSync(dir,{withFileTypes:true});_iterator=_createForOfIteratorHelper(files);_context.prev=2;_iterator.s();case 4:if((_step=_iterator.n()).done){_context.next=20;break;}file=_step.value;if(!file.isDirectory()){_context.next=9;break;}return _context.delegateYield(this._walk(_path["default"].join(dir,file.name)),"t0",8);case 8:return _context.abrupt("continue",18);case 9:filePath=_path["default"].join(dir,file.name);_context.prev=10;this._ensureFileIsNotExcluded(filePath);_context.next=14;return filePath;case 14:_context.next=18;break;case 16:_context.prev=16;_context.t1=_context["catch"](10);case 18:_context.next=4;break;case 20:_context.next=25;break;case 22:_context.prev=22;_context.t2=_context["catch"](2);_iterator.e(_context.t2);case 25:_context.prev=25;_iterator.f();return _context.finish(25);case 28:case"end":return _context.stop();}}},_walk,this,[[2,22,25,28],[10,16]]);})/**
11
+ * @private
12
+ * @param {string} filePath
13
+ * @returns {void}
14
+ */},{key:"_ensureFileIsNotExcluded",value:function _ensureFileIsNotExcluded(filePath){this._excludedFolders.forEach(function(excludedFolder){if(filePath.includes(excludedFolder)){throw new Error('Excluded Folder!');}});}/**
15
+ * @param {string} path
16
+ */},{key:"addExclude",value:function addExclude(relativePath){var fullPathToExclude=_path["default"].join(this._rootDirectory,relativePath);this._excludedFolders.push(fullPathToExclude);}/**
17
+ * @private
18
+ * @param {string} path
19
+ * @param {string} type
20
+ * @param {string} extension
21
+ * @returns {Promise}
22
+ */},{key:"_getServiceIdFromPath",value:function(){var _getServiceIdFromPath2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(path,type){var extension,readableId,_args2=arguments;return _regenerator["default"].wrap(function _callee$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:extension=_args2.length>2&&_args2[2]!==undefined?_args2[2]:'.ts';readableId=path.replace(/\//g,'__').replace(extension,'').replace('@','__').concat("__".concat(type));return _context2.abrupt("return",_AutowireIdentifier["default"].encode(readableId));case 3:case"end":return _context2.stop();}}},_callee);}));function _getServiceIdFromPath(_x,_x2){return _getServiceIdFromPath2.apply(this,arguments);}return _getServiceIdFromPath;}()/**
23
+ * @return {Promise}
24
+ */},{key:"process",value:function(){var _process=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(){var promises,_iterator2,_step2,filePath;return _regenerator["default"].wrap(function _callee2$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:promises=[];_iterator2=_createForOfIteratorHelper(this._walk(this._rootDirectory));try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){filePath=_step2.value;promises.push(this._executeFilePath(filePath));}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}_context3.next=5;return Promise.all(promises);case 5:if(!(this._serviceFile instanceof _ServiceFile["default"])){_context3.next=8;break;}_context3.next=8;return this._serviceFile.generateFromContainer(this._container);case 8:case"end":return _context3.stop();}}},_callee2,this);}));function process(){return _process.apply(this,arguments);}return process;}()/**
25
+ * @param {string} filePath
26
+ * @returns {Promise}
27
+ * @private
28
+ */},{key:"_executeFilePath",value:function(){var _executeFilePath2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(filePath){var parsedFile,_yield$this$_getClass,classDeclaration,body,Class,definition,serviceId;return _regenerator["default"].wrap(function _callee3$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:parsedFile=_path["default"].parse(filePath);if(!(parsedFile.ext!=='.ts')){_context4.next=3;break;}return _context4.abrupt("return");case 3:_context4.next=5;return this._getClassDeclaration(filePath);case 5:_yield$this$_getClass=_context4.sent;classDeclaration=_yield$this$_getClass.classDeclaration;body=_yield$this$_getClass.body;if(classDeclaration){_context4.next=10;break;}return _context4.abrupt("return");case 10:Class=require(filePath)["default"];if(Class){_context4.next=13;break;}return _context4.abrupt("return");case 13:_context4.next=15;return this._getDefinition(classDeclaration,body,parsedFile,Class);case 15:definition=_context4.sent;if(definition){_context4.next=18;break;}return _context4.abrupt("return");case 18:_context4.next=20;return this._getServiceIdFromPath(filePath,Class.name);case 20:serviceId=_context4.sent;this.container.setDefinition(serviceId,definition);_context4.next=24;return this._interfaceImplementations(classDeclaration,body,parsedFile,serviceId);case 24:case"end":return _context4.stop();}}},_callee3,this);}));function _executeFilePath(_x3){return _executeFilePath2.apply(this,arguments);}return _executeFilePath;}()/**
29
+ *
30
+ * @param {string} filePath
31
+ * @returns {Promise}
32
+ * @private
33
+ */},{key:"_getClassDeclaration",value:function(){var _getClassDeclaration2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(filePath){var sourceCode,body,classDeclaration;return _regenerator["default"].wrap(function _callee4$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:sourceCode=_fs["default"].readFileSync(filePath,'utf8');body=(0,_typescriptEstree.parse)(sourceCode).body;classDeclaration=body.find(function(declaration){return declaration.type==='ExportDefaultDeclaration';});return _context5.abrupt("return",{classDeclaration:classDeclaration,body:body});case 4:case"end":return _context5.stop();}}},_callee4);}));function _getClassDeclaration(_x4){return _getClassDeclaration2.apply(this,arguments);}return _getClassDeclaration;}()/**
34
+ *
35
+ * @param {object} classDeclaration
36
+ * @param {string} body
37
+ * @param {any} parsedFile
38
+ * @param {any} ServiceClass
39
+ * @returns
40
+ * @private
41
+ */},{key:"_getDefinition",value:function(){var _getDefinition2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(classDeclaration,body,parsedFile,ServiceClass){var definition,constructorParams,_iterator3,_step3,parameterDeclaration,typeNameForArgument,argumentId;return _regenerator["default"].wrap(function _callee5$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:_context6.prev=0;definition=new _Definition["default"](ServiceClass);_context6.next=4;return this._getConstructorParamsByDefinition(definition,classDeclaration,body,parsedFile);case 4:constructorParams=_context6.sent;_iterator3=_createForOfIteratorHelper(constructorParams);_context6.prev=6;_iterator3.s();case 8:if((_step3=_iterator3.n()).done){_context6.next=19;break;}parameterDeclaration=_step3.value;typeNameForArgument=parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;_context6.next=13;return this._getIdentifierFromImports(typeNameForArgument,body,parsedFile);case 13:argumentId=_context6.sent;if(argumentId){_context6.next=16;break;}return _context6.abrupt("continue",17);case 16:definition.addArgument(new _Reference["default"](argumentId),definition["abstract"]);case 17:_context6.next=8;break;case 19:_context6.next=24;break;case 21:_context6.prev=21;_context6.t0=_context6["catch"](6);_iterator3.e(_context6.t0);case 24:_context6.prev=24;_iterator3.f();return _context6.finish(24);case 27:return _context6.abrupt("return",definition);case 30:_context6.prev=30;_context6.t1=_context6["catch"](0);case 32:case"end":return _context6.stop();}}},_callee5,this,[[0,30],[6,21,24,27]]);}));function _getDefinition(_x5,_x6,_x7,_x8){return _getDefinition2.apply(this,arguments);}return _getDefinition;}()/**
42
+ * @private
43
+ * @param {Definition} definition
44
+ * @param {object} classDeclaration
45
+ * @param {any} body
46
+ * @param {any} parsedFile
47
+ * @returns
48
+ */},{key:"_getConstructorParamsByDefinition",value:function(){var _getConstructorParamsByDefinition2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(definition,classDeclaration,body,parsedFile){var constructorDeclaration;return _regenerator["default"].wrap(function _callee6$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:constructorDeclaration=classDeclaration.declaration.body.body.find(function(method){return method.key.name==='constructor';});if(classDeclaration.declaration["abstract"]){definition["abstract"]=true;}_context7.next=4;return this._parentDefinition(classDeclaration,body,parsedFile,definition);case 4:return _context7.abrupt("return",constructorDeclaration?constructorDeclaration.value.params:[]);case 5:case"end":return _context7.stop();}}},_callee6,this);}));function _getConstructorParamsByDefinition(_x9,_x10,_x11,_x12){return _getConstructorParamsByDefinition2.apply(this,arguments);}return _getConstructorParamsByDefinition;}()/**
49
+ * @private
50
+ * @param {object} classDeclaration
51
+ * @param {any} body
52
+ * @param {any} parsedFile
53
+ * @param {Definition} definition
54
+ */},{key:"_parentDefinition",value:function(){var _parentDefinition2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(classDeclaration,body,parsedFile,definition){var typeParent,parentId;return _regenerator["default"].wrap(function _callee7$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:if(!classDeclaration.declaration.superClass){_context8.next=6;break;}typeParent=classDeclaration.declaration.superClass.name;_context8.next=4;return this._getIdentifierFromImports(typeParent,body,parsedFile);case 4:parentId=_context8.sent;if(parentId){definition.parent=parentId;}case 6:case"end":return _context8.stop();}}},_callee7,this);}));function _parentDefinition(_x13,_x14,_x15,_x16){return _parentDefinition2.apply(this,arguments);}return _parentDefinition;}()/**
55
+ * @private
56
+ * @param {any} classDeclaration
57
+ * @param {any} body
58
+ * @param {any} parsedFile
59
+ * @param {string} serviceId
60
+ */},{key:"_interfaceImplementations",value:function(){var _interfaceImplementations2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(classDeclaration,body,parsedFile,serviceId){var _classDeclaration$dec;var implementations,_iterator4,_step4,implement,interfaceType,aliasId;return _regenerator["default"].wrap(function _callee8$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:implementations=(_classDeclaration$dec=classDeclaration.declaration["implements"])!==null&&_classDeclaration$dec!==void 0?_classDeclaration$dec:[];_iterator4=_createForOfIteratorHelper(implementations);_context9.prev=2;_iterator4.s();case 4:if((_step4=_iterator4.n()).done){_context9.next=15;break;}implement=_step4.value;interfaceType=implement.expression.name;_context9.next=9;return this._getIdentifierFromImports(interfaceType,body,parsedFile);case 9:aliasId=_context9.sent;if(!(!aliasId||this.container.hasAlias(aliasId))){_context9.next=12;break;}return _context9.abrupt("continue",13);case 12:this.container.setAlias(aliasId,serviceId);case 13:_context9.next=4;break;case 15:_context9.next=20;break;case 17:_context9.prev=17;_context9.t0=_context9["catch"](2);_iterator4.e(_context9.t0);case 20:_context9.prev=20;_iterator4.f();return _context9.finish(20);case 23:case"end":return _context9.stop();}}},_callee8,this,[[2,17,20,23]]);}));function _interfaceImplementations(_x17,_x18,_x19,_x20){return _interfaceImplementations2.apply(this,arguments);}return _interfaceImplementations;}()/**
61
+ * @private
62
+ * @param {string} type
63
+ * @param {any} body
64
+ * @param {anty} parsedFile
65
+ * @returns {Promise}
66
+ */},{key:"_getIdentifierFromImports",value:function(){var _getIdentifierFromImports2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(type,body,parsedFile){var _this$_tsConfigPaths,rootDir,relativeImportForImplement,configPaths,pathConfig,tsConfigPath,tsRelativePath,parsedTsConfigPath,absolutePathImportForImplement;return _regenerator["default"].wrap(function _callee9$(_context10){while(1){switch(_context10.prev=_context10.next){case 0:_context10.prev=0;rootDir=parsedFile.dir;_context10.next=4;return this._getRelativeImport(body,type);case 4:relativeImportForImplement=_context10.sent;configPaths=(_this$_tsConfigPaths=this._tsConfigPaths)!==null&&_this$_tsConfigPaths!==void 0?_this$_tsConfigPaths:[];_context10.t0=_regenerator["default"].keys(configPaths);case 7:if((_context10.t1=_context10.t0()).done){_context10.next=18;break;}pathConfig=_context10.t1.value;tsConfigPath=pathConfig.replace(/\*/g,'');tsRelativePath=this._tsConfigPaths[pathConfig][0].replace(/\*/g,'');if(relativeImportForImplement.includes(tsConfigPath)){_context10.next=13;break;}return _context10.abrupt("continue",7);case 13:relativeImportForImplement=relativeImportForImplement.replace(tsConfigPath,tsRelativePath);parsedTsConfigPath=_path["default"].parse(this._tsConfigFullPath);rootDir=parsedTsConfigPath.dir;_context10.next=7;break;case 18:absolutePathImportForImplement=_path["default"].join(rootDir,relativeImportForImplement);return _context10.abrupt("return",this._getServiceIdFromPath(absolutePathImportForImplement,type));case 22:_context10.prev=22;_context10.t2=_context10["catch"](0);case 24:case"end":return _context10.stop();}}},_callee9,this,[[0,22]]);}));function _getIdentifierFromImports(_x21,_x22,_x23){return _getIdentifierFromImports2.apply(this,arguments);}return _getIdentifierFromImports;}()/**
67
+ * @private
68
+ * @param {any} body
69
+ * @param {string} type
70
+ * @returns {Promise}
71
+ */},{key:"_getRelativeImport",value:function(){var _getRelativeImport2=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee10(body,type){return _regenerator["default"].wrap(function _callee10$(_context11){while(1){switch(_context11.prev=_context11.next){case 0:return _context11.abrupt("return",body.find(function(declaration){if(declaration.specifiers){return declaration.specifiers.find(function(specifier){return specifier.local.name===type;});}return null;}).source.value);case 1:case"end":return _context11.stop();}}},_callee10);}));function _getRelativeImport(_x24,_x25){return _getRelativeImport2.apply(this,arguments);}return _getRelativeImport;}()/**
72
+ * @param {ServiceFile} serviceFile
73
+ */},{key:"serviceFile",get:/**
74
+ * @returns {ServiceFile}
75
+ */function get(){return this._serviceFile;},set:function set(serviceFile){this._serviceFile=serviceFile;}}]);return Autowire;}();exports["default"]=Autowire;