@teqfw/di 0.11.0 → 0.12.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teqfw/di",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Dependency Injection container based on logical namespaces for ES6 modules.",
5
5
  "keywords": [
6
6
  "dependency injection",
@@ -27,9 +27,11 @@ TeqFw_Di_Back_Api_Dto_Plugin_Desc.REPLACE = 'replace';
27
27
  * @memberOf TeqFw_Di_Back_Api_Dto_Plugin_Desc
28
28
  */
29
29
  export class Factory {
30
+ static namespace = NS;
31
+
30
32
  constructor(spec) {
31
33
  /** @type {TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload.Factory} */
32
- const fAutoload = spec['TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload#Factory$'];
34
+ const fAutoload = spec['TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload.Factory$'];
33
35
 
34
36
  /**
35
37
  * @param {*} data
@@ -37,7 +39,7 @@ export class Factory {
37
39
  */
38
40
  this.create = function (data = null) {
39
41
 
40
- // DEFINE INNER FUNCTIONS
42
+ // FUNCS
41
43
  function parseReplace(data) {
42
44
  const res = {};
43
45
  if (typeof data === 'object')
@@ -55,7 +57,7 @@ export class Factory {
55
57
  return res;
56
58
  }
57
59
 
58
- // MAIN FUNCTIONALITY
60
+ // MAIN
59
61
  const res = new TeqFw_Di_Back_Api_Dto_Plugin_Desc();
60
62
  res.autoload = fAutoload.create(data?.autoload);
61
63
  res.replace = parseReplace(data?.replace);
@@ -66,4 +68,3 @@ export class Factory {
66
68
 
67
69
  // freeze DTO class to deny attributes changes and pin namespace
68
70
  Object.freeze(TeqFw_Di_Back_Api_Dto_Plugin_Desc);
69
- Object.defineProperty(Factory, 'name', {value: `${NS}.${Factory.constructor.name}`});
@@ -15,15 +15,15 @@ const TEQFW = 'teqfw.json';
15
15
  export default class TeqFw_Di_Back_Plugin_Scanner {
16
16
 
17
17
  constructor(spec) {
18
- // EXTRACT DEPS
18
+ // DEPS
19
19
  /** @type {TeqFw_Di_Back_Defaults} */
20
20
  const DEF = spec['TeqFw_Di_Back_Defaults$'];
21
21
  /** @type {TeqFw_Di_Back_Api_Dto_Plugin_Desc.Factory} */
22
- const fDesc = spec['TeqFw_Di_Back_Api_Dto_Plugin_Desc#Factory$'];
22
+ const fDesc = spec['TeqFw_Di_Back_Api_Dto_Plugin_Desc.Factory$'];
23
23
  /** @type {TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload.Factory} */
24
- const fAutoload = spec['TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload#Factory$'];
24
+ const fAutoload = spec['TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload.Factory$'];
25
25
 
26
- // DEFINE INSTANCE METHODS
26
+ // INSTANCE METHODS
27
27
 
28
28
  this.getDescriptors = async function (path) {
29
29
  const result = [];
@@ -75,9 +75,9 @@ export default class TeqFw_Di_Back_Plugin_Scanner {
75
75
  * @return {Promise<Object.<string, TeqFw_Di_Back_Api_Dto_Scanned>>} Object-to-path map for found plugins
76
76
  */
77
77
  async scanFilesystem(path) {
78
- // DEFINE INNER FUNCTIONS
78
+ // FUNCS
79
79
  function readData(path) {
80
- // DEFINE INNER FUNCTIONS
80
+ // FUNCS
81
81
  /**
82
82
  * Check existence of JSON file, read content, parse JSON and return data.
83
83
  *
@@ -106,7 +106,7 @@ export default class TeqFw_Di_Back_Plugin_Scanner {
106
106
  return result;
107
107
  }
108
108
 
109
- // MAIN FUNCTIONALITY
109
+ // MAIN
110
110
  let result = null;
111
111
  const pathTeqfw = join(path, TEQFW);
112
112
  const pathPkg = join(path, PACKAGE);
@@ -121,7 +121,7 @@ export default class TeqFw_Di_Back_Plugin_Scanner {
121
121
  return result;
122
122
  }
123
123
 
124
- // MAIN FUNCTIONALITY
124
+ // MAIN
125
125
  const result = {};
126
126
  // get scan data for root folder (application itself)
127
127
  const dataRoot = readData(path);
@@ -28,6 +28,8 @@ TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload.PATH = 'path';
28
28
  * @memberOf TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload
29
29
  */
30
30
  export class Factory {
31
+ static namespace = NS;
32
+
31
33
  constructor() {
32
34
  /**
33
35
  * @param {TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload|null} data
@@ -46,4 +48,3 @@ export class Factory {
46
48
 
47
49
  // freeze DTO class to deny attributes changes and pin namespace
48
50
  Object.freeze(TeqFw_Di_Shared_Api_Dto_Plugin_Desc_Autoload);
49
- Object.defineProperty(Factory, 'name', {value: `${NS}.${Factory.constructor.name}`});
@@ -62,7 +62,7 @@ export default class TeqFw_Di_Shared_Container {
62
62
  */
63
63
  async function getObject(mainId, uplineDeps) {
64
64
 
65
- // DEFINE INNER FUNCTIONS
65
+ // FUNCS
66
66
  /**
67
67
  * Add 'spec' proxy as fnConstruct argument and create new object and all deps.
68
68
  *
@@ -73,7 +73,7 @@ export default class TeqFw_Di_Shared_Container {
73
73
  function _useFactory(fnConstruct) {
74
74
  // This promise will be resolved after all dependencies in spec proxy will be created.
75
75
  return new Promise(function (resolve, reject) {
76
- // MAIN FUNCTIONALITY
76
+ // MAIN
77
77
  const constructorType = typeof fnConstruct;
78
78
  if (constructorType === 'object') {
79
79
  // `constructor` is an object, clone this fnConstruct and return cloned object
@@ -162,7 +162,7 @@ export default class TeqFw_Di_Shared_Container {
162
162
  return orig;
163
163
  }
164
164
 
165
- // MAIN FUNCTIONALITY
165
+ // MAIN
166
166
  let result;
167
167
  /** @type {TeqFw_Di_Shared_IdParser_Dto} */
168
168
  const parsed = $parser.parse(mainId);