node-dependency-injection 3.0.0-alpha.6 → 3.0.0-alpha.7
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 +32 -24
- package/package.json +1 -1
package/dist/lib/Autowire.js
CHANGED
|
@@ -215,7 +215,9 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
215
215
|
|
|
216
216
|
var parentId = this._getIdentifierFromImports(typeParent, body, parsedFile);
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
if (parentId) {
|
|
219
|
+
definition.parent = parentId;
|
|
220
|
+
}
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
if (constructorDeclaration) {
|
|
@@ -231,7 +233,9 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
231
233
|
|
|
232
234
|
var argumentId = this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
|
|
233
235
|
|
|
234
|
-
|
|
236
|
+
if (argumentId) {
|
|
237
|
+
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
238
|
+
}
|
|
235
239
|
} catch (e) {}
|
|
236
240
|
}
|
|
237
241
|
} catch (err) {
|
|
@@ -257,7 +261,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
257
261
|
|
|
258
262
|
var aliasId = this._getIdentifierFromImports(interfaceType, body, parsedFile);
|
|
259
263
|
|
|
260
|
-
if (this.container.hasAlias(aliasId) === false) {
|
|
264
|
+
if (aliasId && this.container.hasAlias(aliasId) === false) {
|
|
261
265
|
this.container.setAlias(aliasId, serviceId);
|
|
262
266
|
}
|
|
263
267
|
}
|
|
@@ -271,36 +275,40 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
271
275
|
}, {
|
|
272
276
|
key: "_getIdentifierFromImports",
|
|
273
277
|
value: function _getIdentifierFromImports(type, body, parsedFile) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
try {
|
|
279
|
+
var rootDir = parsedFile.dir;
|
|
280
|
+
var relativeImportForImplement = body.find(function (declaration) {
|
|
281
|
+
if (declaration.specifiers) {
|
|
282
|
+
return declaration.specifiers.find(function (specifier) {
|
|
283
|
+
return specifier.local.name === type;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
281
286
|
|
|
282
|
-
|
|
283
|
-
|
|
287
|
+
return null;
|
|
288
|
+
}).source.value;
|
|
284
289
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
+
if (this._tsConfigPaths) {
|
|
291
|
+
for (var pathConfig in this._tsConfigPaths) {
|
|
292
|
+
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
293
|
+
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
294
|
+
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
290
295
|
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
if (relativeImportForImplement.includes(tsConfigPath)) {
|
|
297
|
+
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
293
298
|
|
|
294
|
-
|
|
299
|
+
var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
|
|
295
300
|
|
|
296
|
-
|
|
301
|
+
rootDir = parsedTsConfigPath.dir;
|
|
302
|
+
}
|
|
297
303
|
}
|
|
298
304
|
}
|
|
299
|
-
}
|
|
300
305
|
|
|
301
|
-
|
|
306
|
+
var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
302
307
|
|
|
303
|
-
|
|
308
|
+
return this._getServiceIdFromPath(absolutePathImportForImplement, type);
|
|
309
|
+
} catch (e) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
304
312
|
}
|
|
305
313
|
}]);
|
|
306
314
|
return Autowire;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-dependency-injection",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.7",
|
|
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": {
|