node-dependency-injection 3.0.0-alpha.9 → 3.0.0-beta.2
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.
- package/CHANGELOG-3.md +4 -1
- package/README.md +39 -3
- package/UPGRADE-3.0.md +3 -1
- package/dist/lib/Autowire.js +463 -122
- package/dist/lib/Compiler.js +169 -40
- package/dist/lib/CompilerPass/DecoratePass.js +57 -36
- package/dist/lib/CompilerPass/index.js +63 -17
- package/dist/lib/ContainerBuilder.js +27 -3
- package/dist/lib/InstanceManager.js +10 -2
- package/dist/lib/Loader/FileLoader.js +223 -59
- package/dist/lib/Loader/JsFileLoader.js +49 -15
- package/dist/lib/Loader/YamlFileLoader.js +70 -24
- package/dist/lib/types/index.d.ts +3 -3
- package/package.json +2 -1
package/dist/lib/Autowire.js
CHANGED
|
@@ -128,46 +128,48 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
128
128
|
})
|
|
129
129
|
}, {
|
|
130
130
|
key: "_getServiceIdFromPath",
|
|
131
|
-
value: function
|
|
132
|
-
var
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
value: function () {
|
|
132
|
+
var _getServiceIdFromPath2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(path, type) {
|
|
133
|
+
var extension,
|
|
134
|
+
_args2 = arguments;
|
|
135
|
+
return _regenerator["default"].wrap(function _callee$(_context2) {
|
|
136
|
+
while (1) {
|
|
137
|
+
switch (_context2.prev = _context2.next) {
|
|
138
|
+
case 0:
|
|
139
|
+
extension = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : '.ts';
|
|
140
|
+
return _context2.abrupt("return", path.replace(/\//g, '_').replace(extension, '').replace('@', '_').concat("_".concat(type)));
|
|
141
|
+
|
|
142
|
+
case 2:
|
|
143
|
+
case "end":
|
|
144
|
+
return _context2.stop();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, _callee);
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
function _getServiceIdFromPath(_x, _x2) {
|
|
151
|
+
return _getServiceIdFromPath2.apply(this, arguments);
|
|
152
|
+
}
|
|
138
153
|
|
|
154
|
+
return _getServiceIdFromPath;
|
|
155
|
+
}()
|
|
139
156
|
}, {
|
|
140
157
|
key: "process",
|
|
141
158
|
value: function () {
|
|
142
|
-
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
143
|
-
var _iterator2, _step2, filePath
|
|
159
|
+
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
160
|
+
var promises, _iterator2, _step2, filePath;
|
|
144
161
|
|
|
145
|
-
return _regenerator["default"].wrap(function
|
|
162
|
+
return _regenerator["default"].wrap(function _callee2$(_context3) {
|
|
146
163
|
while (1) {
|
|
147
|
-
switch (
|
|
164
|
+
switch (_context3.prev = _context3.next) {
|
|
148
165
|
case 0:
|
|
166
|
+
promises = [];
|
|
149
167
|
_iterator2 = _createForOfIteratorHelper(this._walkSync(this._rootDirectory));
|
|
150
168
|
|
|
151
169
|
try {
|
|
152
170
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
153
171
|
filePath = _step2.value;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (parsedFile.ext === '.ts') {
|
|
157
|
-
_this$_getClassDeclar = this._getClassDeclaration(filePath), classDeclaration = _this$_getClassDeclar.classDeclaration, body = _this$_getClassDeclar.body;
|
|
158
|
-
Class = require(filePath)["default"];
|
|
159
|
-
|
|
160
|
-
if (Class && classDeclaration) {
|
|
161
|
-
definition = this._getDefinition(classDeclaration, body, parsedFile, Class);
|
|
162
|
-
|
|
163
|
-
if (definition) {
|
|
164
|
-
serviceId = this._getServiceIdFromPath(filePath, Class.name);
|
|
165
|
-
this.container.setDefinition(serviceId, definition);
|
|
166
|
-
|
|
167
|
-
this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
172
|
+
promises.push(this._executeFilePath(filePath));
|
|
171
173
|
}
|
|
172
174
|
} catch (err) {
|
|
173
175
|
_iterator2.e(err);
|
|
@@ -175,12 +177,15 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
175
177
|
_iterator2.f();
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
|
|
180
|
+
_context3.next = 5;
|
|
181
|
+
return Promise.all(promises);
|
|
182
|
+
|
|
183
|
+
case 5:
|
|
179
184
|
case "end":
|
|
180
|
-
return
|
|
185
|
+
return _context3.stop();
|
|
181
186
|
}
|
|
182
187
|
}
|
|
183
|
-
},
|
|
188
|
+
}, _callee2, this);
|
|
184
189
|
}));
|
|
185
190
|
|
|
186
191
|
function process() {
|
|
@@ -189,133 +194,469 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
189
194
|
|
|
190
195
|
return process;
|
|
191
196
|
}()
|
|
197
|
+
}, {
|
|
198
|
+
key: "_executeFilePath",
|
|
199
|
+
value: function () {
|
|
200
|
+
var _executeFilePath2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(filePath) {
|
|
201
|
+
var parsedFile, _yield$this$_getClass, classDeclaration, body, Class, definition, serviceId;
|
|
202
|
+
|
|
203
|
+
return _regenerator["default"].wrap(function _callee3$(_context4) {
|
|
204
|
+
while (1) {
|
|
205
|
+
switch (_context4.prev = _context4.next) {
|
|
206
|
+
case 0:
|
|
207
|
+
parsedFile = _path["default"].parse(filePath);
|
|
208
|
+
|
|
209
|
+
if (!(parsedFile.ext !== '.ts')) {
|
|
210
|
+
_context4.next = 3;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return _context4.abrupt("return");
|
|
215
|
+
|
|
216
|
+
case 3:
|
|
217
|
+
_context4.next = 5;
|
|
218
|
+
return this._getClassDeclaration(filePath);
|
|
219
|
+
|
|
220
|
+
case 5:
|
|
221
|
+
_yield$this$_getClass = _context4.sent;
|
|
222
|
+
classDeclaration = _yield$this$_getClass.classDeclaration;
|
|
223
|
+
body = _yield$this$_getClass.body;
|
|
224
|
+
|
|
225
|
+
if (classDeclaration) {
|
|
226
|
+
_context4.next = 10;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return _context4.abrupt("return");
|
|
231
|
+
|
|
232
|
+
case 10:
|
|
233
|
+
Class = require(filePath)["default"];
|
|
234
|
+
|
|
235
|
+
if (Class) {
|
|
236
|
+
_context4.next = 13;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return _context4.abrupt("return");
|
|
241
|
+
|
|
242
|
+
case 13:
|
|
243
|
+
_context4.next = 15;
|
|
244
|
+
return this._getDefinition(classDeclaration, body, parsedFile, Class);
|
|
245
|
+
|
|
246
|
+
case 15:
|
|
247
|
+
definition = _context4.sent;
|
|
248
|
+
|
|
249
|
+
if (definition) {
|
|
250
|
+
_context4.next = 18;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return _context4.abrupt("return");
|
|
255
|
+
|
|
256
|
+
case 18:
|
|
257
|
+
_context4.next = 20;
|
|
258
|
+
return this._getServiceIdFromPath(filePath, Class.name);
|
|
259
|
+
|
|
260
|
+
case 20:
|
|
261
|
+
serviceId = _context4.sent;
|
|
262
|
+
this.container.setDefinition(serviceId, definition);
|
|
263
|
+
_context4.next = 24;
|
|
264
|
+
return this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
|
|
265
|
+
|
|
266
|
+
case 24:
|
|
267
|
+
case "end":
|
|
268
|
+
return _context4.stop();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, _callee3, this);
|
|
272
|
+
}));
|
|
273
|
+
|
|
274
|
+
function _executeFilePath(_x3) {
|
|
275
|
+
return _executeFilePath2.apply(this, arguments);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return _executeFilePath;
|
|
279
|
+
}()
|
|
192
280
|
}, {
|
|
193
281
|
key: "_getClassDeclaration",
|
|
194
|
-
value: function
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
282
|
+
value: function () {
|
|
283
|
+
var _getClassDeclaration2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(filePath) {
|
|
284
|
+
var sourceCode, body, classDeclaration;
|
|
285
|
+
return _regenerator["default"].wrap(function _callee4$(_context5) {
|
|
286
|
+
while (1) {
|
|
287
|
+
switch (_context5.prev = _context5.next) {
|
|
288
|
+
case 0:
|
|
289
|
+
sourceCode = _fs["default"].readFileSync(filePath, 'utf8');
|
|
290
|
+
body = (0, _typescriptEstree.parse)(sourceCode).body;
|
|
291
|
+
classDeclaration = body.find(function (declaration) {
|
|
292
|
+
return declaration.type === 'ExportDefaultDeclaration';
|
|
293
|
+
});
|
|
294
|
+
return _context5.abrupt("return", {
|
|
295
|
+
classDeclaration: classDeclaration,
|
|
296
|
+
body: body
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
case 4:
|
|
300
|
+
case "end":
|
|
301
|
+
return _context5.stop();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}, _callee4);
|
|
305
|
+
}));
|
|
306
|
+
|
|
307
|
+
function _getClassDeclaration(_x4) {
|
|
308
|
+
return _getClassDeclaration2.apply(this, arguments);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return _getClassDeclaration;
|
|
312
|
+
}()
|
|
206
313
|
}, {
|
|
207
314
|
key: "_getDefinition",
|
|
208
|
-
value: function
|
|
209
|
-
|
|
210
|
-
var definition
|
|
211
|
-
var constructorDeclaration = classDeclaration.declaration.body.body.find(function (method) {
|
|
212
|
-
return method.key.name === 'constructor';
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
if (classDeclaration.declaration["abstract"]) {
|
|
216
|
-
definition["abstract"] = true;
|
|
217
|
-
}
|
|
315
|
+
value: function () {
|
|
316
|
+
var _getDefinition2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(classDeclaration, body, parsedFile, ServiceClass) {
|
|
317
|
+
var definition, constructorParams, _iterator3, _step3, parameterDeclaration, typeNameForArgument, argumentId;
|
|
218
318
|
|
|
219
|
-
|
|
220
|
-
|
|
319
|
+
return _regenerator["default"].wrap(function _callee5$(_context6) {
|
|
320
|
+
while (1) {
|
|
321
|
+
switch (_context6.prev = _context6.next) {
|
|
322
|
+
case 0:
|
|
323
|
+
_context6.prev = 0;
|
|
324
|
+
definition = new _Definition["default"](ServiceClass);
|
|
325
|
+
_context6.next = 4;
|
|
326
|
+
return this._getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile);
|
|
327
|
+
|
|
328
|
+
case 4:
|
|
329
|
+
constructorParams = _context6.sent;
|
|
330
|
+
_iterator3 = _createForOfIteratorHelper(constructorParams);
|
|
331
|
+
_context6.prev = 6;
|
|
332
|
+
|
|
333
|
+
_iterator3.s();
|
|
334
|
+
|
|
335
|
+
case 8:
|
|
336
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
337
|
+
_context6.next = 19;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
parameterDeclaration = _step3.value;
|
|
342
|
+
typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
343
|
+
_context6.next = 13;
|
|
344
|
+
return this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
|
|
345
|
+
|
|
346
|
+
case 13:
|
|
347
|
+
argumentId = _context6.sent;
|
|
348
|
+
|
|
349
|
+
if (argumentId) {
|
|
350
|
+
_context6.next = 16;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return _context6.abrupt("continue", 17);
|
|
355
|
+
|
|
356
|
+
case 16:
|
|
357
|
+
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
358
|
+
|
|
359
|
+
case 17:
|
|
360
|
+
_context6.next = 8;
|
|
361
|
+
break;
|
|
221
362
|
|
|
222
|
-
|
|
363
|
+
case 19:
|
|
364
|
+
_context6.next = 24;
|
|
365
|
+
break;
|
|
366
|
+
|
|
367
|
+
case 21:
|
|
368
|
+
_context6.prev = 21;
|
|
369
|
+
_context6.t0 = _context6["catch"](6);
|
|
370
|
+
|
|
371
|
+
_iterator3.e(_context6.t0);
|
|
372
|
+
|
|
373
|
+
case 24:
|
|
374
|
+
_context6.prev = 24;
|
|
375
|
+
|
|
376
|
+
_iterator3.f();
|
|
377
|
+
|
|
378
|
+
return _context6.finish(24);
|
|
223
379
|
|
|
224
|
-
|
|
225
|
-
|
|
380
|
+
case 27:
|
|
381
|
+
return _context6.abrupt("return", definition);
|
|
382
|
+
|
|
383
|
+
case 30:
|
|
384
|
+
_context6.prev = 30;
|
|
385
|
+
_context6.t1 = _context6["catch"](0);
|
|
386
|
+
|
|
387
|
+
case 32:
|
|
388
|
+
return _context6.abrupt("return", null);
|
|
389
|
+
|
|
390
|
+
case 33:
|
|
391
|
+
case "end":
|
|
392
|
+
return _context6.stop();
|
|
393
|
+
}
|
|
226
394
|
}
|
|
227
|
-
}
|
|
395
|
+
}, _callee5, this, [[0, 30], [6, 21, 24, 27]]);
|
|
396
|
+
}));
|
|
397
|
+
|
|
398
|
+
function _getDefinition(_x5, _x6, _x7, _x8) {
|
|
399
|
+
return _getDefinition2.apply(this, arguments);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return _getDefinition;
|
|
403
|
+
}()
|
|
404
|
+
}, {
|
|
405
|
+
key: "_getConstructorParamsByDefinition",
|
|
406
|
+
value: function () {
|
|
407
|
+
var _getConstructorParamsByDefinition2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(definition, classDeclaration, body, parsedFile) {
|
|
408
|
+
var constructorDeclaration, constructorParams;
|
|
409
|
+
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
410
|
+
while (1) {
|
|
411
|
+
switch (_context7.prev = _context7.next) {
|
|
412
|
+
case 0:
|
|
413
|
+
constructorDeclaration = classDeclaration.declaration.body.body.find(function (method) {
|
|
414
|
+
return method.key.name === 'constructor';
|
|
415
|
+
});
|
|
228
416
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
417
|
+
if (classDeclaration.declaration["abstract"]) {
|
|
418
|
+
definition["abstract"] = true;
|
|
419
|
+
}
|
|
232
420
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
var parameterDeclaration = _step3.value;
|
|
236
|
-
var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
421
|
+
_context7.next = 4;
|
|
422
|
+
return this._parentDefinition(classDeclaration, body, parsedFile, definition);
|
|
237
423
|
|
|
238
|
-
|
|
424
|
+
case 4:
|
|
425
|
+
constructorParams = constructorDeclaration ? constructorDeclaration.value.params : [];
|
|
426
|
+
return _context7.abrupt("return", constructorParams);
|
|
239
427
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
428
|
+
case 6:
|
|
429
|
+
case "end":
|
|
430
|
+
return _context7.stop();
|
|
243
431
|
}
|
|
244
|
-
} catch (err) {
|
|
245
|
-
_iterator3.e(err);
|
|
246
|
-
} finally {
|
|
247
|
-
_iterator3.f();
|
|
248
432
|
}
|
|
249
|
-
}
|
|
433
|
+
}, _callee6, this);
|
|
434
|
+
}));
|
|
250
435
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return null;
|
|
436
|
+
function _getConstructorParamsByDefinition(_x9, _x10, _x11, _x12) {
|
|
437
|
+
return _getConstructorParamsByDefinition2.apply(this, arguments);
|
|
254
438
|
}
|
|
255
|
-
|
|
439
|
+
|
|
440
|
+
return _getConstructorParamsByDefinition;
|
|
441
|
+
}()
|
|
442
|
+
}, {
|
|
443
|
+
key: "_parentDefinition",
|
|
444
|
+
value: function () {
|
|
445
|
+
var _parentDefinition2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(classDeclaration, body, parsedFile, definition) {
|
|
446
|
+
var typeParent, parentId;
|
|
447
|
+
return _regenerator["default"].wrap(function _callee7$(_context8) {
|
|
448
|
+
while (1) {
|
|
449
|
+
switch (_context8.prev = _context8.next) {
|
|
450
|
+
case 0:
|
|
451
|
+
if (!classDeclaration.declaration.superClass) {
|
|
452
|
+
_context8.next = 6;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
typeParent = classDeclaration.declaration.superClass.name;
|
|
457
|
+
_context8.next = 4;
|
|
458
|
+
return this._getIdentifierFromImports(typeParent, body, parsedFile);
|
|
459
|
+
|
|
460
|
+
case 4:
|
|
461
|
+
parentId = _context8.sent;
|
|
462
|
+
|
|
463
|
+
if (parentId) {
|
|
464
|
+
definition.parent = parentId;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
case 6:
|
|
468
|
+
case "end":
|
|
469
|
+
return _context8.stop();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}, _callee7, this);
|
|
473
|
+
}));
|
|
474
|
+
|
|
475
|
+
function _parentDefinition(_x13, _x14, _x15, _x16) {
|
|
476
|
+
return _parentDefinition2.apply(this, arguments);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return _parentDefinition;
|
|
480
|
+
}()
|
|
256
481
|
}, {
|
|
257
482
|
key: "_interfaceImplementations",
|
|
258
|
-
value: function
|
|
259
|
-
|
|
260
|
-
var
|
|
261
|
-
|
|
483
|
+
value: function () {
|
|
484
|
+
var _interfaceImplementations2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(classDeclaration, body, parsedFile, serviceId) {
|
|
485
|
+
var _classDeclaration$dec;
|
|
486
|
+
|
|
487
|
+
var implementations, _iterator4, _step4, implement, interfaceType, aliasId;
|
|
488
|
+
|
|
489
|
+
return _regenerator["default"].wrap(function _callee8$(_context9) {
|
|
490
|
+
while (1) {
|
|
491
|
+
switch (_context9.prev = _context9.next) {
|
|
492
|
+
case 0:
|
|
493
|
+
implementations = (_classDeclaration$dec = classDeclaration.declaration["implements"]) !== null && _classDeclaration$dec !== void 0 ? _classDeclaration$dec : [];
|
|
494
|
+
_iterator4 = _createForOfIteratorHelper(implementations);
|
|
495
|
+
_context9.prev = 2;
|
|
496
|
+
|
|
497
|
+
_iterator4.s();
|
|
498
|
+
|
|
499
|
+
case 4:
|
|
500
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
501
|
+
_context9.next = 15;
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
implement = _step4.value;
|
|
506
|
+
interfaceType = implement.expression.name;
|
|
507
|
+
_context9.next = 9;
|
|
508
|
+
return this._getIdentifierFromImports(interfaceType, body, parsedFile);
|
|
509
|
+
|
|
510
|
+
case 9:
|
|
511
|
+
aliasId = _context9.sent;
|
|
512
|
+
|
|
513
|
+
if (!(!aliasId || this.container.hasAlias(aliasId))) {
|
|
514
|
+
_context9.next = 12;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
262
517
|
|
|
263
|
-
|
|
264
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
265
|
-
var implement = _step4.value;
|
|
266
|
-
var interfaceType = implement.expression.name;
|
|
518
|
+
return _context9.abrupt("continue", 13);
|
|
267
519
|
|
|
268
|
-
|
|
520
|
+
case 12:
|
|
521
|
+
this.container.setAlias(aliasId, serviceId);
|
|
269
522
|
|
|
270
|
-
|
|
271
|
-
|
|
523
|
+
case 13:
|
|
524
|
+
_context9.next = 4;
|
|
525
|
+
break;
|
|
526
|
+
|
|
527
|
+
case 15:
|
|
528
|
+
_context9.next = 20;
|
|
529
|
+
break;
|
|
530
|
+
|
|
531
|
+
case 17:
|
|
532
|
+
_context9.prev = 17;
|
|
533
|
+
_context9.t0 = _context9["catch"](2);
|
|
534
|
+
|
|
535
|
+
_iterator4.e(_context9.t0);
|
|
536
|
+
|
|
537
|
+
case 20:
|
|
538
|
+
_context9.prev = 20;
|
|
539
|
+
|
|
540
|
+
_iterator4.f();
|
|
541
|
+
|
|
542
|
+
return _context9.finish(20);
|
|
543
|
+
|
|
544
|
+
case 23:
|
|
545
|
+
case "end":
|
|
546
|
+
return _context9.stop();
|
|
272
547
|
}
|
|
273
548
|
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
549
|
+
}, _callee8, this, [[2, 17, 20, 23]]);
|
|
550
|
+
}));
|
|
551
|
+
|
|
552
|
+
function _interfaceImplementations(_x17, _x18, _x19, _x20) {
|
|
553
|
+
return _interfaceImplementations2.apply(this, arguments);
|
|
279
554
|
}
|
|
280
|
-
|
|
555
|
+
|
|
556
|
+
return _interfaceImplementations;
|
|
557
|
+
}()
|
|
281
558
|
}, {
|
|
282
559
|
key: "_getIdentifierFromImports",
|
|
283
|
-
value: function
|
|
284
|
-
|
|
285
|
-
var rootDir
|
|
286
|
-
var relativeImportForImplement = body.find(function (declaration) {
|
|
287
|
-
if (declaration.specifiers) {
|
|
288
|
-
return declaration.specifiers.find(function (specifier) {
|
|
289
|
-
return specifier.local.name === type;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
560
|
+
value: function () {
|
|
561
|
+
var _getIdentifierFromImports2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(type, body, parsedFile) {
|
|
562
|
+
var _this$_tsConfigPaths, rootDir, relativeImportForImplement, configPaths, pathConfig, tsConfigPath, tsRelativePath, parsedTsConfigPath, absolutePathImportForImplement;
|
|
292
563
|
|
|
293
|
-
|
|
294
|
-
|
|
564
|
+
return _regenerator["default"].wrap(function _callee9$(_context10) {
|
|
565
|
+
while (1) {
|
|
566
|
+
switch (_context10.prev = _context10.next) {
|
|
567
|
+
case 0:
|
|
568
|
+
_context10.prev = 0;
|
|
569
|
+
rootDir = parsedFile.dir;
|
|
570
|
+
_context10.next = 4;
|
|
571
|
+
return this._getRelativeImport(body, type);
|
|
572
|
+
|
|
573
|
+
case 4:
|
|
574
|
+
relativeImportForImplement = _context10.sent;
|
|
575
|
+
configPaths = (_this$_tsConfigPaths = this._tsConfigPaths) !== null && _this$_tsConfigPaths !== void 0 ? _this$_tsConfigPaths : [];
|
|
576
|
+
_context10.t0 = _regenerator["default"].keys(configPaths);
|
|
577
|
+
|
|
578
|
+
case 7:
|
|
579
|
+
if ((_context10.t1 = _context10.t0()).done) {
|
|
580
|
+
_context10.next = 19;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
295
583
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
584
|
+
pathConfig = _context10.t1.value;
|
|
585
|
+
tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
586
|
+
tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
587
|
+
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
301
588
|
|
|
302
|
-
|
|
303
|
-
|
|
589
|
+
if (relativeImportForImplement.includes(tsConfigPath)) {
|
|
590
|
+
_context10.next = 14;
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return _context10.abrupt("continue", 7);
|
|
304
595
|
|
|
305
|
-
|
|
596
|
+
case 14:
|
|
597
|
+
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
598
|
+
parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
|
|
599
|
+
rootDir = parsedTsConfigPath.dir;
|
|
600
|
+
_context10.next = 7;
|
|
601
|
+
break;
|
|
306
602
|
|
|
307
|
-
|
|
603
|
+
case 19:
|
|
604
|
+
absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
605
|
+
return _context10.abrupt("return", this._getServiceIdFromPath(absolutePathImportForImplement, type));
|
|
606
|
+
|
|
607
|
+
case 23:
|
|
608
|
+
_context10.prev = 23;
|
|
609
|
+
_context10.t2 = _context10["catch"](0);
|
|
610
|
+
|
|
611
|
+
case 25:
|
|
612
|
+
return _context10.abrupt("return", null);
|
|
613
|
+
|
|
614
|
+
case 26:
|
|
615
|
+
case "end":
|
|
616
|
+
return _context10.stop();
|
|
308
617
|
}
|
|
309
618
|
}
|
|
310
|
-
}
|
|
619
|
+
}, _callee9, this, [[0, 23]]);
|
|
620
|
+
}));
|
|
311
621
|
|
|
312
|
-
|
|
622
|
+
function _getIdentifierFromImports(_x21, _x22, _x23) {
|
|
623
|
+
return _getIdentifierFromImports2.apply(this, arguments);
|
|
624
|
+
}
|
|
313
625
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
626
|
+
return _getIdentifierFromImports;
|
|
627
|
+
}()
|
|
628
|
+
}, {
|
|
629
|
+
key: "_getRelativeImport",
|
|
630
|
+
value: function () {
|
|
631
|
+
var _getRelativeImport2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(body, type) {
|
|
632
|
+
return _regenerator["default"].wrap(function _callee10$(_context11) {
|
|
633
|
+
while (1) {
|
|
634
|
+
switch (_context11.prev = _context11.next) {
|
|
635
|
+
case 0:
|
|
636
|
+
return _context11.abrupt("return", body.find(function (declaration) {
|
|
637
|
+
if (declaration.specifiers) {
|
|
638
|
+
return declaration.specifiers.find(function (specifier) {
|
|
639
|
+
return specifier.local.name === type;
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
return null;
|
|
644
|
+
}).source.value);
|
|
645
|
+
|
|
646
|
+
case 1:
|
|
647
|
+
case "end":
|
|
648
|
+
return _context11.stop();
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}, _callee10);
|
|
652
|
+
}));
|
|
653
|
+
|
|
654
|
+
function _getRelativeImport(_x24, _x25) {
|
|
655
|
+
return _getRelativeImport2.apply(this, arguments);
|
|
317
656
|
}
|
|
318
|
-
|
|
657
|
+
|
|
658
|
+
return _getRelativeImport;
|
|
659
|
+
}()
|
|
319
660
|
}]);
|
|
320
661
|
return Autowire;
|
|
321
662
|
}();
|