node-dependency-injection 3.0.0-beta.0 → 3.0.0-beta.3

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.
@@ -27,6 +27,8 @@ var _Definition = _interopRequireDefault(require("./Definition"));
27
27
 
28
28
  var _Reference = _interopRequireDefault(require("./Reference"));
29
29
 
30
+ var _ServiceFile = _interopRequireDefault(require("./ServiceFile"));
31
+
30
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; } } }; }
31
33
 
32
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); }
@@ -40,6 +42,8 @@ var Autowire = /*#__PURE__*/function () {
40
42
  this._interfaceImplementation = new Map();
41
43
  this._rootDirectory = container.defaultDir;
42
44
  this._container = container;
45
+ this._excludedFolders = [];
46
+ this._dumpServiceFile = null;
43
47
 
44
48
  try {
45
49
  this._tsConfigFullPath = tsConfigFullPath || _path["default"].join(process.cwd(), 'tsconfig.json');
@@ -58,12 +62,18 @@ var Autowire = /*#__PURE__*/function () {
58
62
  get: function get() {
59
63
  return this._container;
60
64
  }
65
+ /**
66
+ * @private
67
+ */
68
+
61
69
  }, {
62
- key: "_walkSync",
63
- value: /*#__PURE__*/_regenerator["default"].mark(function _walkSync(dir) {
64
- var files, _iterator, _step, file;
70
+ key: "_walk",
71
+ value:
72
+ /*#__PURE__*/
73
+ _regenerator["default"].mark(function _walk(dir) {
74
+ var files, _iterator, _step, file, filePath;
65
75
 
66
- return _regenerator["default"].wrap(function _walkSync$(_context) {
76
+ return _regenerator["default"].wrap(function _walk$(_context) {
67
77
  while (1) {
68
78
  switch (_context.prev = _context.next) {
69
79
  case 0:
@@ -77,317 +87,705 @@ var Autowire = /*#__PURE__*/function () {
77
87
 
78
88
  case 4:
79
89
  if ((_step = _iterator.n()).done) {
80
- _context.next = 14;
90
+ _context.next = 20;
81
91
  break;
82
92
  }
83
93
 
84
94
  file = _step.value;
85
95
 
86
96
  if (!file.isDirectory()) {
87
- _context.next = 10;
97
+ _context.next = 9;
88
98
  break;
89
99
  }
90
100
 
91
- return _context.delegateYield(this._walkSync(_path["default"].join(dir, file.name)), "t0", 8);
101
+ return _context.delegateYield(this._walk(_path["default"].join(dir, file.name)), "t0", 8);
92
102
 
93
103
  case 8:
94
- _context.next = 12;
95
- break;
104
+ return _context.abrupt("continue", 18);
96
105
 
97
- case 10:
98
- _context.next = 12;
99
- return _path["default"].join(dir, file.name);
106
+ case 9:
107
+ filePath = _path["default"].join(dir, file.name);
108
+ _context.prev = 10;
100
109
 
101
- case 12:
102
- _context.next = 4;
103
- break;
110
+ this._ensureFileIsNotExcluded(filePath);
111
+
112
+ _context.next = 14;
113
+ return filePath;
104
114
 
105
115
  case 14:
106
- _context.next = 19;
116
+ _context.next = 18;
107
117
  break;
108
118
 
109
119
  case 16:
110
120
  _context.prev = 16;
111
- _context.t1 = _context["catch"](2);
121
+ _context.t1 = _context["catch"](10);
112
122
 
113
- _iterator.e(_context.t1);
123
+ case 18:
124
+ _context.next = 4;
125
+ break;
114
126
 
115
- case 19:
116
- _context.prev = 19;
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;
117
139
 
118
140
  _iterator.f();
119
141
 
120
- return _context.finish(19);
142
+ return _context.finish(25);
121
143
 
122
- case 22:
144
+ case 28:
123
145
  case "end":
124
146
  return _context.stop();
125
147
  }
126
148
  }
127
- }, _walkSync, this, [[2, 16, 19, 22]]);
149
+ }, _walk, this, [[2, 22, 25, 28], [10, 16]]);
128
150
  })
151
+ /**
152
+ * @private
153
+ * @param {string} filePath
154
+ * @returns {void}
155
+ */
156
+
129
157
  }, {
130
- key: "_getServiceIdFromPath",
131
- value: function _getServiceIdFromPath(path, type) {
132
- var extension = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.ts';
133
- return path.replace(/\//g, '_').replace(extension, '').replace('@', '_').concat("_".concat(type));
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
+ });
134
165
  }
166
+ /**
167
+ * @param {string} path
168
+ */
169
+
135
170
  }, {
136
- key: "process",
137
- value: function () {
138
- var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
139
- var _iterator2, _step2, filePath, parsedFile, _this$_getClassDeclar, classDeclaration, body, Class, definition, serviceId;
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
+ */
140
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;
141
191
  return _regenerator["default"].wrap(function _callee$(_context2) {
142
192
  while (1) {
143
193
  switch (_context2.prev = _context2.next) {
144
194
  case 0:
145
- _iterator2 = _createForOfIteratorHelper(this._walkSync(this._rootDirectory));
146
- _context2.prev = 1;
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
+ }
147
239
 
148
- _iterator2.s();
240
+ _context3.next = 5;
241
+ return Promise.all(promises);
149
242
 
150
- case 3:
151
- if ((_step2 = _iterator2.n()).done) {
152
- _context2.next = 22;
243
+ case 5:
244
+ if (!(this._dumpServiceFile instanceof _ServiceFile["default"])) {
245
+ _context3.next = 8;
153
246
  break;
154
247
  }
155
248
 
156
- filePath = _step2.value;
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:
157
282
  parsedFile = _path["default"].parse(filePath);
158
283
 
159
284
  if (!(parsedFile.ext !== '.ts')) {
160
- _context2.next = 8;
285
+ _context4.next = 3;
161
286
  break;
162
287
  }
163
288
 
164
- return _context2.abrupt("continue", 20);
289
+ return _context4.abrupt("return");
165
290
 
166
- case 8:
167
- _this$_getClassDeclar = this._getClassDeclaration(filePath), classDeclaration = _this$_getClassDeclar.classDeclaration, body = _this$_getClassDeclar.body;
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;
168
299
 
169
300
  if (classDeclaration) {
170
- _context2.next = 11;
301
+ _context4.next = 10;
171
302
  break;
172
303
  }
173
304
 
174
- return _context2.abrupt("continue", 20);
305
+ return _context4.abrupt("return");
175
306
 
176
- case 11:
307
+ case 10:
177
308
  Class = require(filePath)["default"];
178
309
 
179
310
  if (Class) {
180
- _context2.next = 14;
311
+ _context4.next = 13;
181
312
  break;
182
313
  }
183
314
 
184
- return _context2.abrupt("continue", 20);
315
+ return _context4.abrupt("return");
316
+
317
+ case 13:
318
+ _context4.next = 15;
319
+ return this._getDefinition(classDeclaration, body, parsedFile, Class);
185
320
 
186
- case 14:
187
- definition = this._getDefinition(classDeclaration, body, parsedFile, Class);
321
+ case 15:
322
+ definition = _context4.sent;
188
323
 
189
324
  if (definition) {
190
- _context2.next = 17;
325
+ _context4.next = 18;
191
326
  break;
192
327
  }
193
328
 
194
- return _context2.abrupt("continue", 20);
329
+ return _context4.abrupt("return");
195
330
 
196
- case 17:
197
- serviceId = this._getServiceIdFromPath(filePath, Class.name);
198
- this.container.setDefinition(serviceId, definition);
199
-
200
- this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
331
+ case 18:
332
+ _context4.next = 20;
333
+ return this._getServiceIdFromPath(filePath, Class.name);
201
334
 
202
335
  case 20:
203
- _context2.next = 3;
204
- break;
205
-
206
- case 22:
207
- _context2.next = 27;
208
- break;
336
+ serviceId = _context4.sent;
337
+ this.container.setDefinition(serviceId, definition);
338
+ _context4.next = 24;
339
+ return this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
209
340
 
210
341
  case 24:
211
- _context2.prev = 24;
212
- _context2.t0 = _context2["catch"](1);
213
-
214
- _iterator2.e(_context2.t0);
215
-
216
- case 27:
217
- _context2.prev = 27;
342
+ case "end":
343
+ return _context4.stop();
344
+ }
345
+ }
346
+ }, _callee3, this);
347
+ }));
218
348
 
219
- _iterator2.f();
349
+ function _executeFilePath(_x3) {
350
+ return _executeFilePath2.apply(this, arguments);
351
+ }
220
352
 
221
- return _context2.finish(27);
353
+ return _executeFilePath;
354
+ }()
355
+ /**
356
+ *
357
+ * @param {string} filePath
358
+ * @returns {Promise}
359
+ * @private
360
+ */
222
361
 
223
- case 30:
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:
224
382
  case "end":
225
- return _context2.stop();
383
+ return _context5.stop();
226
384
  }
227
385
  }
228
- }, _callee, this, [[1, 24, 27, 30]]);
386
+ }, _callee4);
229
387
  }));
230
388
 
231
- function process() {
232
- return _process.apply(this, arguments);
389
+ function _getClassDeclaration(_x4) {
390
+ return _getClassDeclaration2.apply(this, arguments);
233
391
  }
234
392
 
235
- return process;
393
+ return _getClassDeclaration;
236
394
  }()
237
- }, {
238
- key: "_getClassDeclaration",
239
- value: function _getClassDeclaration(filePath) {
240
- var sourceCode = _fs["default"].readFileSync(filePath, 'utf8');
395
+ /**
396
+ *
397
+ * @param {object} classDeclaration
398
+ * @param {string} body
399
+ * @param {any} parsedFile
400
+ * @param {any} ServiceClass
401
+ * @returns
402
+ * @private
403
+ */
241
404
 
242
- var body = (0, _typescriptEstree.parse)(sourceCode).body;
243
- var classDeclaration = body.find(function (declaration) {
244
- return declaration.type === 'ExportDefaultDeclaration';
245
- });
246
- return {
247
- classDeclaration: classDeclaration,
248
- body: body
249
- };
250
- }
251
405
  }, {
252
406
  key: "_getDefinition",
253
- value: function _getDefinition(classDeclaration, body, parsedFile, ServiceClass) {
254
- try {
255
- var definition = new _Definition["default"](ServiceClass);
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;
256
410
 
257
- var constructorParams = this._getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile);
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);
258
419
 
259
- var _iterator3 = _createForOfIteratorHelper(constructorParams),
260
- _step3;
420
+ case 4:
421
+ constructorParams = _context6.sent;
422
+ _iterator3 = _createForOfIteratorHelper(constructorParams);
423
+ _context6.prev = 6;
261
424
 
262
- try {
263
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
264
- var parameterDeclaration = _step3.value;
265
- var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
425
+ _iterator3.s();
266
426
 
267
- var argumentId = this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
427
+ case 8:
428
+ if ((_step3 = _iterator3.n()).done) {
429
+ _context6.next = 19;
430
+ break;
431
+ }
268
432
 
269
- if (!argumentId) {
270
- continue;
271
- }
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();
272
469
 
273
- definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
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
+ }
274
483
  }
275
- } catch (err) {
276
- _iterator3.e(err);
277
- } finally {
278
- _iterator3.f();
279
- }
484
+ }, _callee5, this, [[0, 30], [6, 21, 24, 27]]);
485
+ }));
280
486
 
281
- return definition;
282
- } catch (e) {}
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
+ */
283
501
 
284
- return null;
285
- }
286
502
  }, {
287
503
  key: "_getConstructorParamsByDefinition",
288
- value: function _getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile) {
289
- var constructorDeclaration = classDeclaration.declaration.body.body.find(function (method) {
290
- return method.key.name === 'constructor';
291
- });
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
+ }));
292
533
 
293
- if (classDeclaration.declaration["abstract"]) {
294
- definition["abstract"] = true;
534
+ function _getConstructorParamsByDefinition(_x9, _x10, _x11, _x12) {
535
+ return _getConstructorParamsByDefinition2.apply(this, arguments);
295
536
  }
296
537
 
297
- this._parentDefinition(classDeclaration, body, parsedFile, definition);
538
+ return _getConstructorParamsByDefinition;
539
+ }()
540
+ /**
541
+ * @private
542
+ * @param {object} classDeclaration
543
+ * @param {any} body
544
+ * @param {any} parsedFile
545
+ * @param {Definition} definition
546
+ */
298
547
 
299
- var constructorParams = constructorDeclaration ? constructorDeclaration.value.params : [];
300
- return constructorParams;
301
- }
302
548
  }, {
303
549
  key: "_parentDefinition",
304
- value: function _parentDefinition(classDeclaration, body, parsedFile, definition) {
305
- if (classDeclaration.declaration.superClass) {
306
- var typeParent = classDeclaration.declaration.superClass.name;
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
+ }
307
561
 
308
- var parentId = this._getIdentifierFromImports(typeParent, body, parsedFile);
562
+ typeParent = classDeclaration.declaration.superClass.name;
563
+ _context8.next = 4;
564
+ return this._getIdentifierFromImports(typeParent, body, parsedFile);
309
565
 
310
- if (parentId) {
311
- definition.parent = parentId;
312
- }
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);
313
583
  }
314
- }
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
+
315
595
  }, {
316
596
  key: "_interfaceImplementations",
317
- value: function _interfaceImplementations(classDeclaration, body, parsedFile, serviceId) {
318
- var _classDeclaration$dec;
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();
319
612
 
320
- var implementations = (_classDeclaration$dec = classDeclaration.declaration["implements"]) !== null && _classDeclaration$dec !== void 0 ? _classDeclaration$dec : [];
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;
321
626
 
322
- var _iterator4 = _createForOfIteratorHelper(implementations),
323
- _step4;
627
+ if (!(!aliasId || this.container.hasAlias(aliasId))) {
628
+ _context9.next = 12;
629
+ break;
630
+ }
324
631
 
325
- try {
326
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
327
- var implement = _step4.value;
328
- var interfaceType = implement.expression.name;
632
+ return _context9.abrupt("continue", 13);
329
633
 
330
- var aliasId = this._getIdentifierFromImports(interfaceType, body, parsedFile);
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;
331
653
 
332
- if (!aliasId || this.container.hasAlias(aliasId)) {
333
- continue;
654
+ _iterator4.f();
655
+
656
+ return _context9.finish(20);
657
+
658
+ case 23:
659
+ case "end":
660
+ return _context9.stop();
661
+ }
334
662
  }
663
+ }, _callee8, this, [[2, 17, 20, 23]]);
664
+ }));
335
665
 
336
- this.container.setAlias(aliasId, serviceId);
337
- }
338
- } catch (err) {
339
- _iterator4.e(err);
340
- } finally {
341
- _iterator4.f();
666
+ function _interfaceImplementations(_x17, _x18, _x19, _x20) {
667
+ return _interfaceImplementations2.apply(this, arguments);
342
668
  }
343
- }
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
+
344
680
  }, {
345
681
  key: "_getIdentifierFromImports",
346
- value: function _getIdentifierFromImports(type, body, parsedFile) {
347
- try {
348
- var _this$_tsConfigPaths;
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;
349
685
 
350
- var rootDir = parsedFile.dir;
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
+ }
351
705
 
352
- var relativeImportForImplement = this._getRelativeImport(body, type);
706
+ pathConfig = _context10.t1.value;
707
+ tsConfigPath = pathConfig.replace(/\*/g, '');
708
+ tsRelativePath = this._tsConfigPaths[pathConfig][0].replace(/\*/g, '');
353
709
 
354
- var configPaths = (_this$_tsConfigPaths = this._tsConfigPaths) !== null && _this$_tsConfigPaths !== void 0 ? _this$_tsConfigPaths : [];
710
+ if (relativeImportForImplement.includes(tsConfigPath)) {
711
+ _context10.next = 13;
712
+ break;
713
+ }
355
714
 
356
- for (var pathConfig in configPaths) {
357
- var tsConfigPath = pathConfig.replace(/\*/g, '');
358
- var tsRelativePath = this._tsConfigPaths[pathConfig][0];
359
- tsRelativePath = tsRelativePath.replace(/\*/g, '');
715
+ return _context10.abrupt("continue", 7);
360
716
 
361
- if (!relativeImportForImplement.includes(tsConfigPath)) {
362
- continue;
363
- }
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;
364
723
 
365
- relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
724
+ case 18:
725
+ absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
726
+ return _context10.abrupt("return", this._getServiceIdFromPath(absolutePathImportForImplement, type));
366
727
 
367
- var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
728
+ case 22:
729
+ _context10.prev = 22;
730
+ _context10.t2 = _context10["catch"](0);
368
731
 
369
- rootDir = parsedTsConfigPath.dir;
370
- }
732
+ case 24:
733
+ case "end":
734
+ return _context10.stop();
735
+ }
736
+ }
737
+ }, _callee9, this, [[0, 22]]);
738
+ }));
371
739
 
372
- var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
740
+ function _getIdentifierFromImports(_x21, _x22, _x23) {
741
+ return _getIdentifierFromImports2.apply(this, arguments);
742
+ }
373
743
 
374
- return this._getServiceIdFromPath(absolutePathImportForImplement, type);
375
- } catch (e) {}
744
+ return _getIdentifierFromImports;
745
+ }()
746
+ /**
747
+ * @private
748
+ * @param {any} body
749
+ * @param {string} type
750
+ * @returns {Promise}
751
+ */
376
752
 
377
- return null;
378
- }
379
753
  }, {
380
754
  key: "_getRelativeImport",
381
- value: function _getRelativeImport(body, type) {
382
- return body.find(function (declaration) {
383
- if (declaration.specifiers) {
384
- return declaration.specifiers.find(function (specifier) {
385
- return specifier.local.name === type;
386
- });
387
- }
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
+ }));
388
778
 
389
- return null;
390
- }).source.value;
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);
391
789
  }
392
790
  }]);
393
791
  return Autowire;