node-dependency-injection 3.0.0-beta.0 → 3.0.0-beta.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.
- package/dist/lib/Autowire.js +429 -161
- package/package.json +1 -1
package/dist/lib/Autowire.js
CHANGED
|
@@ -128,267 +128,535 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
128
128
|
})
|
|
129
129
|
}, {
|
|
130
130
|
key: "_getServiceIdFromPath",
|
|
131
|
-
value: function
|
|
132
|
-
var
|
|
133
|
-
|
|
134
|
-
|
|
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
|
+
}
|
|
153
|
+
|
|
154
|
+
return _getServiceIdFromPath;
|
|
155
|
+
}()
|
|
135
156
|
}, {
|
|
136
157
|
key: "process",
|
|
137
158
|
value: function () {
|
|
138
|
-
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
139
|
-
var _iterator2, _step2, filePath
|
|
159
|
+
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
160
|
+
var promises, _iterator2, _step2, filePath;
|
|
140
161
|
|
|
141
|
-
return _regenerator["default"].wrap(function
|
|
162
|
+
return _regenerator["default"].wrap(function _callee2$(_context3) {
|
|
142
163
|
while (1) {
|
|
143
|
-
switch (
|
|
164
|
+
switch (_context3.prev = _context3.next) {
|
|
144
165
|
case 0:
|
|
166
|
+
promises = [];
|
|
145
167
|
_iterator2 = _createForOfIteratorHelper(this._walkSync(this._rootDirectory));
|
|
146
|
-
_context2.prev = 1;
|
|
147
|
-
|
|
148
|
-
_iterator2.s();
|
|
149
168
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
169
|
+
try {
|
|
170
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
171
|
+
filePath = _step2.value;
|
|
172
|
+
promises.push(this._executeFilePath(filePath));
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
_iterator2.e(err);
|
|
176
|
+
} finally {
|
|
177
|
+
_iterator2.f();
|
|
154
178
|
}
|
|
155
179
|
|
|
156
|
-
|
|
180
|
+
_context3.next = 5;
|
|
181
|
+
return Promise.all(promises);
|
|
182
|
+
|
|
183
|
+
case 5:
|
|
184
|
+
case "end":
|
|
185
|
+
return _context3.stop();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, _callee2, this);
|
|
189
|
+
}));
|
|
190
|
+
|
|
191
|
+
function process() {
|
|
192
|
+
return _process.apply(this, arguments);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return process;
|
|
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:
|
|
157
207
|
parsedFile = _path["default"].parse(filePath);
|
|
158
208
|
|
|
159
209
|
if (!(parsedFile.ext !== '.ts')) {
|
|
160
|
-
|
|
210
|
+
_context4.next = 3;
|
|
161
211
|
break;
|
|
162
212
|
}
|
|
163
213
|
|
|
164
|
-
return
|
|
214
|
+
return _context4.abrupt("return");
|
|
165
215
|
|
|
166
|
-
case
|
|
167
|
-
|
|
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;
|
|
168
224
|
|
|
169
225
|
if (classDeclaration) {
|
|
170
|
-
|
|
226
|
+
_context4.next = 10;
|
|
171
227
|
break;
|
|
172
228
|
}
|
|
173
229
|
|
|
174
|
-
return
|
|
230
|
+
return _context4.abrupt("return");
|
|
175
231
|
|
|
176
|
-
case
|
|
232
|
+
case 10:
|
|
177
233
|
Class = require(filePath)["default"];
|
|
178
234
|
|
|
179
235
|
if (Class) {
|
|
180
|
-
|
|
236
|
+
_context4.next = 13;
|
|
181
237
|
break;
|
|
182
238
|
}
|
|
183
239
|
|
|
184
|
-
return
|
|
240
|
+
return _context4.abrupt("return");
|
|
185
241
|
|
|
186
|
-
case
|
|
187
|
-
|
|
242
|
+
case 13:
|
|
243
|
+
_context4.next = 15;
|
|
244
|
+
return this._getDefinition(classDeclaration, body, parsedFile, Class);
|
|
245
|
+
|
|
246
|
+
case 15:
|
|
247
|
+
definition = _context4.sent;
|
|
188
248
|
|
|
189
249
|
if (definition) {
|
|
190
|
-
|
|
250
|
+
_context4.next = 18;
|
|
191
251
|
break;
|
|
192
252
|
}
|
|
193
253
|
|
|
194
|
-
return
|
|
254
|
+
return _context4.abrupt("return");
|
|
195
255
|
|
|
196
|
-
case
|
|
197
|
-
|
|
256
|
+
case 18:
|
|
257
|
+
_context4.next = 20;
|
|
258
|
+
return this._getServiceIdFromPath(filePath, Class.name);
|
|
259
|
+
|
|
260
|
+
case 20:
|
|
261
|
+
serviceId = _context4.sent;
|
|
198
262
|
this.container.setDefinition(serviceId, definition);
|
|
263
|
+
_context4.next = 24;
|
|
264
|
+
return this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
|
|
199
265
|
|
|
200
|
-
|
|
266
|
+
case 24:
|
|
267
|
+
case "end":
|
|
268
|
+
return _context4.stop();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, _callee3, this);
|
|
272
|
+
}));
|
|
201
273
|
|
|
202
|
-
|
|
203
|
-
|
|
274
|
+
function _executeFilePath(_x3) {
|
|
275
|
+
return _executeFilePath2.apply(this, arguments);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return _executeFilePath;
|
|
279
|
+
}()
|
|
280
|
+
}, {
|
|
281
|
+
key: "_getClassDeclaration",
|
|
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
|
+
}()
|
|
313
|
+
}, {
|
|
314
|
+
key: "_getDefinition",
|
|
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;
|
|
318
|
+
|
|
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;
|
|
204
361
|
break;
|
|
205
362
|
|
|
206
|
-
case
|
|
207
|
-
|
|
363
|
+
case 19:
|
|
364
|
+
_context6.next = 24;
|
|
208
365
|
break;
|
|
209
366
|
|
|
367
|
+
case 21:
|
|
368
|
+
_context6.prev = 21;
|
|
369
|
+
_context6.t0 = _context6["catch"](6);
|
|
370
|
+
|
|
371
|
+
_iterator3.e(_context6.t0);
|
|
372
|
+
|
|
210
373
|
case 24:
|
|
211
|
-
|
|
212
|
-
|
|
374
|
+
_context6.prev = 24;
|
|
375
|
+
|
|
376
|
+
_iterator3.f();
|
|
213
377
|
|
|
214
|
-
|
|
378
|
+
return _context6.finish(24);
|
|
215
379
|
|
|
216
380
|
case 27:
|
|
217
|
-
|
|
381
|
+
return _context6.abrupt("return", definition);
|
|
218
382
|
|
|
219
|
-
|
|
383
|
+
case 30:
|
|
384
|
+
_context6.prev = 30;
|
|
385
|
+
_context6.t1 = _context6["catch"](0);
|
|
220
386
|
|
|
221
|
-
|
|
387
|
+
case 32:
|
|
388
|
+
return _context6.abrupt("return", null);
|
|
222
389
|
|
|
223
|
-
case
|
|
390
|
+
case 33:
|
|
224
391
|
case "end":
|
|
225
|
-
return
|
|
392
|
+
return _context6.stop();
|
|
226
393
|
}
|
|
227
394
|
}
|
|
228
|
-
},
|
|
395
|
+
}, _callee5, this, [[0, 30], [6, 21, 24, 27]]);
|
|
229
396
|
}));
|
|
230
397
|
|
|
231
|
-
function
|
|
232
|
-
return
|
|
398
|
+
function _getDefinition(_x5, _x6, _x7, _x8) {
|
|
399
|
+
return _getDefinition2.apply(this, arguments);
|
|
233
400
|
}
|
|
234
401
|
|
|
235
|
-
return
|
|
402
|
+
return _getDefinition;
|
|
236
403
|
}()
|
|
237
404
|
}, {
|
|
238
|
-
key: "
|
|
239
|
-
value: function
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
}, {
|
|
252
|
-
key: "_getDefinition",
|
|
253
|
-
value: function _getDefinition(classDeclaration, body, parsedFile, ServiceClass) {
|
|
254
|
-
try {
|
|
255
|
-
var definition = new _Definition["default"](ServiceClass);
|
|
256
|
-
|
|
257
|
-
var constructorParams = this._getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile);
|
|
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
|
+
});
|
|
258
416
|
|
|
259
|
-
|
|
260
|
-
|
|
417
|
+
if (classDeclaration.declaration["abstract"]) {
|
|
418
|
+
definition["abstract"] = true;
|
|
419
|
+
}
|
|
261
420
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
var parameterDeclaration = _step3.value;
|
|
265
|
-
var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
421
|
+
_context7.next = 4;
|
|
422
|
+
return this._parentDefinition(classDeclaration, body, parsedFile, definition);
|
|
266
423
|
|
|
267
|
-
|
|
424
|
+
case 4:
|
|
425
|
+
constructorParams = constructorDeclaration ? constructorDeclaration.value.params : [];
|
|
426
|
+
return _context7.abrupt("return", constructorParams);
|
|
268
427
|
|
|
269
|
-
|
|
270
|
-
|
|
428
|
+
case 6:
|
|
429
|
+
case "end":
|
|
430
|
+
return _context7.stop();
|
|
271
431
|
}
|
|
272
|
-
|
|
273
|
-
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
274
432
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
} finally {
|
|
278
|
-
_iterator3.f();
|
|
279
|
-
}
|
|
433
|
+
}, _callee6, this);
|
|
434
|
+
}));
|
|
280
435
|
|
|
281
|
-
|
|
282
|
-
|
|
436
|
+
function _getConstructorParamsByDefinition(_x9, _x10, _x11, _x12) {
|
|
437
|
+
return _getConstructorParamsByDefinition2.apply(this, arguments);
|
|
438
|
+
}
|
|
283
439
|
|
|
284
|
-
return
|
|
285
|
-
}
|
|
440
|
+
return _getConstructorParamsByDefinition;
|
|
441
|
+
}()
|
|
286
442
|
}, {
|
|
287
|
-
key: "
|
|
288
|
-
value: function
|
|
289
|
-
var
|
|
290
|
-
|
|
291
|
-
|
|
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
|
+
}
|
|
292
455
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
456
|
+
typeParent = classDeclaration.declaration.superClass.name;
|
|
457
|
+
_context8.next = 4;
|
|
458
|
+
return this._getIdentifierFromImports(typeParent, body, parsedFile);
|
|
296
459
|
|
|
297
|
-
|
|
460
|
+
case 4:
|
|
461
|
+
parentId = _context8.sent;
|
|
298
462
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}, {
|
|
303
|
-
key: "_parentDefinition",
|
|
304
|
-
value: function _parentDefinition(classDeclaration, body, parsedFile, definition) {
|
|
305
|
-
if (classDeclaration.declaration.superClass) {
|
|
306
|
-
var typeParent = classDeclaration.declaration.superClass.name;
|
|
463
|
+
if (parentId) {
|
|
464
|
+
definition.parent = parentId;
|
|
465
|
+
}
|
|
307
466
|
|
|
308
|
-
|
|
467
|
+
case 6:
|
|
468
|
+
case "end":
|
|
469
|
+
return _context8.stop();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}, _callee7, this);
|
|
473
|
+
}));
|
|
309
474
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
475
|
+
function _parentDefinition(_x13, _x14, _x15, _x16) {
|
|
476
|
+
return _parentDefinition2.apply(this, arguments);
|
|
313
477
|
}
|
|
314
|
-
|
|
478
|
+
|
|
479
|
+
return _parentDefinition;
|
|
480
|
+
}()
|
|
315
481
|
}, {
|
|
316
482
|
key: "_interfaceImplementations",
|
|
317
|
-
value: function
|
|
318
|
-
var
|
|
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
|
+
}
|
|
319
517
|
|
|
320
|
-
|
|
518
|
+
return _context9.abrupt("continue", 13);
|
|
321
519
|
|
|
322
|
-
|
|
323
|
-
|
|
520
|
+
case 12:
|
|
521
|
+
this.container.setAlias(aliasId, serviceId);
|
|
324
522
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
var interfaceType = implement.expression.name;
|
|
523
|
+
case 13:
|
|
524
|
+
_context9.next = 4;
|
|
525
|
+
break;
|
|
329
526
|
|
|
330
|
-
|
|
527
|
+
case 15:
|
|
528
|
+
_context9.next = 20;
|
|
529
|
+
break;
|
|
331
530
|
|
|
332
|
-
|
|
333
|
-
|
|
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();
|
|
547
|
+
}
|
|
334
548
|
}
|
|
549
|
+
}, _callee8, this, [[2, 17, 20, 23]]);
|
|
550
|
+
}));
|
|
335
551
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
} catch (err) {
|
|
339
|
-
_iterator4.e(err);
|
|
340
|
-
} finally {
|
|
341
|
-
_iterator4.f();
|
|
552
|
+
function _interfaceImplementations(_x17, _x18, _x19, _x20) {
|
|
553
|
+
return _interfaceImplementations2.apply(this, arguments);
|
|
342
554
|
}
|
|
343
|
-
|
|
555
|
+
|
|
556
|
+
return _interfaceImplementations;
|
|
557
|
+
}()
|
|
344
558
|
}, {
|
|
345
559
|
key: "_getIdentifierFromImports",
|
|
346
|
-
value: function
|
|
347
|
-
|
|
348
|
-
var _this$_tsConfigPaths;
|
|
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;
|
|
349
563
|
|
|
350
|
-
|
|
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
|
+
}
|
|
351
583
|
|
|
352
|
-
|
|
584
|
+
pathConfig = _context10.t1.value;
|
|
585
|
+
tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
586
|
+
tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
587
|
+
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
353
588
|
|
|
354
|
-
|
|
589
|
+
if (relativeImportForImplement.includes(tsConfigPath)) {
|
|
590
|
+
_context10.next = 14;
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
355
593
|
|
|
356
|
-
|
|
357
|
-
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
358
|
-
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
359
|
-
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
594
|
+
return _context10.abrupt("continue", 7);
|
|
360
595
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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;
|
|
364
602
|
|
|
365
|
-
|
|
603
|
+
case 19:
|
|
604
|
+
absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
605
|
+
return _context10.abrupt("return", this._getServiceIdFromPath(absolutePathImportForImplement, type));
|
|
366
606
|
|
|
367
|
-
|
|
607
|
+
case 23:
|
|
608
|
+
_context10.prev = 23;
|
|
609
|
+
_context10.t2 = _context10["catch"](0);
|
|
368
610
|
|
|
369
|
-
|
|
370
|
-
|
|
611
|
+
case 25:
|
|
612
|
+
return _context10.abrupt("return", null);
|
|
371
613
|
|
|
372
|
-
|
|
614
|
+
case 26:
|
|
615
|
+
case "end":
|
|
616
|
+
return _context10.stop();
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}, _callee9, this, [[0, 23]]);
|
|
620
|
+
}));
|
|
373
621
|
|
|
374
|
-
|
|
375
|
-
|
|
622
|
+
function _getIdentifierFromImports(_x21, _x22, _x23) {
|
|
623
|
+
return _getIdentifierFromImports2.apply(this, arguments);
|
|
624
|
+
}
|
|
376
625
|
|
|
377
|
-
return
|
|
378
|
-
}
|
|
626
|
+
return _getIdentifierFromImports;
|
|
627
|
+
}()
|
|
379
628
|
}, {
|
|
380
629
|
key: "_getRelativeImport",
|
|
381
|
-
value: function
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
+
}
|
|
388
642
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return _getRelativeImport;
|
|
659
|
+
}()
|
|
392
660
|
}]);
|
|
393
661
|
return Autowire;
|
|
394
662
|
}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-dependency-injection",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "The NodeDependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.",
|
|
5
5
|
"main": "dist/lib/index.js",
|
|
6
6
|
"directories": {
|