@teqfw/di 2.0.3 → 2.0.5
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.md +13 -0
- package/README.md +220 -149
- package/ai/AGENTS.md +8 -7
- package/ai/package-api.ts +440 -0
- package/dist/esm.js +1 -1
- package/dist/umd.js +1 -1
- package/package.json +1 -2
- package/src/AGENTS.md +5 -5
- package/src/Container.mjs +9 -6
- package/src/Def/Parser.mjs +7 -7
- package/src/Dto/DepId.mjs +8 -13
- package/src/Dto/Resolver/Config/Namespace.mjs +13 -18
- package/src/Dto/Resolver/Config.mjs +14 -20
- package/src/Enum/Composition.mjs +1 -1
- package/src/Enum/Life.mjs +1 -1
- package/src/Enum/Platform.mjs +1 -1
- package/types.d.ts +8 -5
- package/jsconfig.json +0 -13
package/src/Container.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import TeqFw_Di_Def_Parser from './Def/Parser.mjs';
|
|
4
|
-
import
|
|
4
|
+
import {Factory as TeqFw_Di_Dto_Resolver_Config_Factory} from './Dto/Resolver/Config.mjs';
|
|
5
5
|
import TeqFw_Di_Resolver from './Container/Resolver.mjs';
|
|
6
6
|
import TeqFw_Di_Container_Resolve_GraphResolver from './Container/Resolve/GraphResolver.mjs';
|
|
7
7
|
import TeqFw_Di_Container_Instantiate_Instantiator from './Container/Instantiate/Instantiator.mjs';
|
|
@@ -19,6 +19,9 @@ import TeqFw_Di_Internal_Logger, {TeqFw_Di_Internal_Logger_Noop} from './Interna
|
|
|
19
19
|
* Executes immutable linking pipeline:
|
|
20
20
|
* parse -> preprocess -> resolve graph -> instantiate -> postprocess ->
|
|
21
21
|
* lifecycle -> freeze -> return.
|
|
22
|
+
*
|
|
23
|
+
* @LLM-DOC
|
|
24
|
+
* Spec: ./ctx/docs/code/components/container.md
|
|
22
25
|
*/
|
|
23
26
|
export default class TeqFw_Di_Container {
|
|
24
27
|
/**
|
|
@@ -31,7 +34,7 @@ export default class TeqFw_Di_Container {
|
|
|
31
34
|
const preprocess = [];
|
|
32
35
|
/** @type {((value: unknown) => unknown)[]} */
|
|
33
36
|
const postprocess = [];
|
|
34
|
-
/** @type {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO
|
|
37
|
+
/** @type {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO[]} */
|
|
35
38
|
const namespaceRoots = [];
|
|
36
39
|
/** @type {Map<string, unknown>} */
|
|
37
40
|
const mockRegistry = new Map();
|
|
@@ -40,8 +43,8 @@ export default class TeqFw_Di_Container {
|
|
|
40
43
|
|
|
41
44
|
/** @type {TeqFw_Di_Def_Parser} */
|
|
42
45
|
let parser = new TeqFw_Di_Def_Parser();
|
|
43
|
-
/** @type {TeqFw_Di_Dto_Resolver_Config} */
|
|
44
|
-
const configFactory = new
|
|
46
|
+
/** @type {TeqFw_Di_Dto_Resolver_Config$Factory} */
|
|
47
|
+
const configFactory = new TeqFw_Di_Dto_Resolver_Config_Factory();
|
|
45
48
|
/** @type {TeqFw_Di_Resolver|undefined} */
|
|
46
49
|
let resolver;
|
|
47
50
|
/** @type {TeqFw_Di_Container_Resolve_GraphResolver|undefined} */
|
|
@@ -169,7 +172,7 @@ export default class TeqFw_Di_Container {
|
|
|
169
172
|
state = 'operational';
|
|
170
173
|
const resolverConfig = configFactory.create({
|
|
171
174
|
namespaces: namespaceRoots,
|
|
172
|
-
}
|
|
175
|
+
});
|
|
173
176
|
if (typeof parser.setLogger === 'function') parser.setLogger(logger);
|
|
174
177
|
resolver = new TeqFw_Di_Resolver({config: resolverConfig, logger});
|
|
175
178
|
graphResolver = new TeqFw_Di_Container_Resolve_GraphResolver({parser, resolver, logger});
|
|
@@ -271,7 +274,7 @@ export default class TeqFw_Di_Container {
|
|
|
271
274
|
* Resolves dependency by CDC and returns frozen linked value.
|
|
272
275
|
*
|
|
273
276
|
* @param {string} cdc
|
|
274
|
-
* @returns {Promise<
|
|
277
|
+
* @returns {Promise<any>}
|
|
275
278
|
*/
|
|
276
279
|
this.get = async function (cdc) {
|
|
277
280
|
if (state === 'failed') {
|
package/src/Def/Parser.mjs
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
import TeqFw_Di_Enum_Composition from '../Enum/Composition.mjs';
|
|
4
4
|
import TeqFw_Di_Enum_Life from '../Enum/Life.mjs';
|
|
5
5
|
import TeqFw_Di_Enum_Platform from '../Enum/Platform.mjs';
|
|
6
|
-
import
|
|
6
|
+
import {Factory as TeqFw_Di_Dto_DepId_Factory} from '../Dto/DepId.mjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Parser for CDC identifiers into
|
|
10
|
-
|
|
9
|
+
* Parser for CDC identifiers into frozen dependency identity DTO.
|
|
10
|
+
*/
|
|
11
11
|
export default class TeqFw_Di_Def_Parser {
|
|
12
12
|
/**
|
|
13
13
|
* Creates parser instance.
|
|
14
14
|
*/
|
|
15
15
|
constructor() {
|
|
16
|
-
/** @type {
|
|
17
|
-
const depIdFactory = new
|
|
16
|
+
/** @type {TeqFw_Di_Dto_DepId$Factory} Factory used to construct dependency identity DTO. */
|
|
17
|
+
const depIdFactory = new TeqFw_Di_Dto_DepId_Factory();
|
|
18
18
|
/** @type {{log(message: string): void}|null} */
|
|
19
19
|
let logger = null;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Parses one CDC identifier and returns normalized
|
|
22
|
+
* Parses one CDC identifier and returns normalized frozen dependency DTO.
|
|
23
23
|
*
|
|
24
24
|
* @param {string} cdc CDC identifier string.
|
|
25
25
|
* @returns {TeqFw_Di_DepId$DTO}
|
|
@@ -128,7 +128,7 @@ export default class TeqFw_Di_Def_Parser {
|
|
|
128
128
|
life,
|
|
129
129
|
wrappers,
|
|
130
130
|
origin,
|
|
131
|
-
}
|
|
131
|
+
});
|
|
132
132
|
if (logger) logger.log(`Parser.parse: produced='${depId.platform}::${depId.moduleName}'.`);
|
|
133
133
|
return depId;
|
|
134
134
|
};
|
package/src/Dto/DepId.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import TeqFw_Di_Enum_Life from '../Enum/Life.mjs';
|
|
|
5
5
|
import TeqFw_Di_Enum_Platform from '../Enum/Platform.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* DTO
|
|
8
|
+
* DTO for dependency identity records and its factory.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/** @type {typeof TeqFw_Di_Enum_Platform[keyof typeof TeqFw_Di_Enum_Platform]} */
|
|
@@ -23,7 +23,7 @@ const LIFE_VALUES = new Set(Object.values(TeqFw_Di_Enum_Life));
|
|
|
23
23
|
/**
|
|
24
24
|
* Runtime DTO for parsed dependency identity.
|
|
25
25
|
*/
|
|
26
|
-
export class DTO {
|
|
26
|
+
export default class DTO {
|
|
27
27
|
/** @type {string} Resolved module namespace. */
|
|
28
28
|
moduleName;
|
|
29
29
|
|
|
@@ -47,17 +47,16 @@ export class DTO {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Factory for dependency identity DTO
|
|
50
|
+
* Factory for immutable dependency identity DTO.
|
|
51
51
|
*/
|
|
52
|
-
export
|
|
52
|
+
export class Factory {
|
|
53
53
|
/**
|
|
54
|
-
* Creates normalized dependency identity DTO.
|
|
54
|
+
* Creates normalized frozen dependency identity DTO.
|
|
55
55
|
*
|
|
56
56
|
* @param {unknown} [input]
|
|
57
|
-
* @param {{immutable?: boolean}} [options]
|
|
58
57
|
* @returns {TeqFw_Di_DepId$DTO}
|
|
59
58
|
*/
|
|
60
|
-
create(input
|
|
59
|
+
create(input) {
|
|
61
60
|
/** @type {Record<string, unknown>} */
|
|
62
61
|
const source = (input && typeof input === 'object')
|
|
63
62
|
? /** @type {Record<string, unknown>} */ (input)
|
|
@@ -121,11 +120,7 @@ export default class Factory {
|
|
|
121
120
|
? source.origin
|
|
122
121
|
: '';
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Object.freeze(dto);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return dto;
|
|
123
|
+
Object.freeze(dto.wrappers);
|
|
124
|
+
return Object.freeze(dto);
|
|
130
125
|
}
|
|
131
126
|
}
|
|
@@ -1,48 +1,43 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* DTO
|
|
4
|
+
* DTO for resolver namespace rule records and its factory.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Runtime DTO for one namespace resolution rule.
|
|
9
9
|
*/
|
|
10
|
-
export class DTO {
|
|
10
|
+
export default class DTO {
|
|
11
11
|
/** @type {string|undefined} Namespace prefix in depId module name. */
|
|
12
12
|
prefix;
|
|
13
|
+
|
|
13
14
|
/** @type {string|undefined} Import target base for matched namespace. */
|
|
14
15
|
target;
|
|
16
|
+
|
|
15
17
|
/** @type {string|undefined} Default extension appended to matched module path. */
|
|
16
18
|
defaultExt;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
|
-
* Factory for resolver namespace DTO
|
|
22
|
+
* Factory for immutable resolver namespace DTO.
|
|
21
23
|
*/
|
|
22
|
-
export
|
|
24
|
+
export class Factory {
|
|
23
25
|
/**
|
|
24
|
-
* Creates normalized resolver namespace DTO.
|
|
26
|
+
* Creates normalized frozen resolver namespace DTO.
|
|
25
27
|
*
|
|
26
|
-
* @param {Partial<TeqFw_Di_Dto_Resolver_Config_Namespace$DTO
|
|
27
|
-
* @
|
|
28
|
-
* @returns {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO$}
|
|
28
|
+
* @param {Partial<TeqFw_Di_Dto_Resolver_Config_Namespace$DTO>|Record<string, unknown>} [input] Source values.
|
|
29
|
+
* @returns {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO}
|
|
29
30
|
*/
|
|
30
|
-
create(input
|
|
31
|
-
/** @type {Partial<TeqFw_Di_Dto_Resolver_Config_Namespace$DTO
|
|
31
|
+
create(input) {
|
|
32
|
+
/** @type {Partial<TeqFw_Di_Dto_Resolver_Config_Namespace$DTO>|Record<string, unknown>} */
|
|
32
33
|
const source = (input && (typeof input === 'object')) ? input : {};
|
|
33
|
-
/** @type {{immutable?: boolean}|Record<string, unknown>} */
|
|
34
|
-
const mode = (options && (typeof options === 'object')) ? options : {};
|
|
35
34
|
|
|
36
|
-
/** @type {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO
|
|
35
|
+
/** @type {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO} */
|
|
37
36
|
const dto = new DTO();
|
|
38
37
|
dto.prefix = (typeof source.prefix === 'string') ? source.prefix : undefined;
|
|
39
38
|
dto.target = (typeof source.target === 'string') ? source.target : undefined;
|
|
40
39
|
dto.defaultExt = (typeof source.defaultExt === 'string') ? source.defaultExt : undefined;
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
Object.freeze(dto);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return dto;
|
|
41
|
+
return Object.freeze(dto);
|
|
47
42
|
}
|
|
48
43
|
}
|
|
@@ -1,58 +1,52 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import {Factory as TeqFw_Di_Dto_Resolver_Config_Namespace_Factory} from './Config/Namespace.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* DTO
|
|
6
|
+
* DTO for resolver configuration records and its factory.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Runtime DTO for resolver configuration.
|
|
11
11
|
*/
|
|
12
|
-
export class DTO {
|
|
13
|
-
/** @type {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO
|
|
12
|
+
export default class DTO {
|
|
13
|
+
/** @type {TeqFw_Di_Dto_Resolver_Config_Namespace$DTO[]} Namespace resolution rules. */
|
|
14
14
|
namespaces;
|
|
15
|
+
|
|
15
16
|
/** @type {string|undefined} Optional node_modules root prefix for npm modules. */
|
|
16
17
|
nodeModulesRoot;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
* Factory for resolver configuration DTO
|
|
21
|
+
* Factory for immutable resolver configuration DTO.
|
|
21
22
|
*/
|
|
22
|
-
export
|
|
23
|
+
export class Factory {
|
|
23
24
|
/**
|
|
24
25
|
* Creates factory instance.
|
|
25
26
|
*/
|
|
26
27
|
constructor() {
|
|
27
|
-
/** @type {
|
|
28
|
-
const nsFactory = new
|
|
28
|
+
/** @type {TeqFw_Di_Dto_Resolver_Config_Namespace_Factory} */
|
|
29
|
+
const nsFactory = new TeqFw_Di_Dto_Resolver_Config_Namespace_Factory();
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
|
-
* Creates normalized resolver configuration DTO.
|
|
32
|
+
* Creates normalized frozen resolver configuration DTO.
|
|
32
33
|
*
|
|
33
34
|
* @param {Partial<TeqFw_Di_Dto_Resolver_Config$DTO>|Record<string, unknown>} [input] Source values.
|
|
34
|
-
* @param {{immutable?: boolean}|Record<string, unknown>} [options] Factory options.
|
|
35
35
|
* @returns {TeqFw_Di_Dto_Resolver_Config$DTO}
|
|
36
36
|
*/
|
|
37
|
-
this.create = function (input
|
|
37
|
+
this.create = function (input) {
|
|
38
38
|
/** @type {Partial<TeqFw_Di_Dto_Resolver_Config$DTO>|Record<string, unknown>} */
|
|
39
39
|
const source = (input && (typeof input === 'object')) ? input : {};
|
|
40
|
-
/** @type {{immutable?: boolean}|Record<string, unknown>} */
|
|
41
|
-
const mode = (options && (typeof options === 'object')) ? options : {};
|
|
42
40
|
|
|
43
41
|
/** @type {TeqFw_Di_Dto_Resolver_Config$DTO} */
|
|
44
42
|
const dto = new DTO();
|
|
45
43
|
/** @type {unknown[]} */
|
|
46
44
|
const items = Array.isArray(source.namespaces) ? source.namespaces : [];
|
|
47
|
-
dto.namespaces = items.map((item) => nsFactory.create(item
|
|
45
|
+
dto.namespaces = items.map((item) => nsFactory.create(item));
|
|
48
46
|
dto.nodeModulesRoot = (typeof source.nodeModulesRoot === 'string') ? source.nodeModulesRoot : undefined;
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Object.freeze(dto);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return dto;
|
|
48
|
+
Object.freeze(dto.namespaces);
|
|
49
|
+
return Object.freeze(dto);
|
|
56
50
|
};
|
|
57
51
|
}
|
|
58
52
|
}
|
package/src/Enum/Composition.mjs
CHANGED
package/src/Enum/Life.mjs
CHANGED
package/src/Enum/Platform.mjs
CHANGED
package/types.d.ts
CHANGED
|
@@ -8,14 +8,17 @@ declare global {
|
|
|
8
8
|
type TeqFw_Di_Container_Wrapper_Executor = import("./src/Container/Wrapper/Executor.mjs").default;
|
|
9
9
|
type TeqFw_Di_Def_Parser = import("./src/Def/Parser.mjs").default;
|
|
10
10
|
type TeqFw_Di_DepId = import("./src/Dto/DepId.mjs").default;
|
|
11
|
-
type TeqFw_Di_DepId$DTO = import("./src/Dto/DepId.mjs").
|
|
11
|
+
type TeqFw_Di_DepId$DTO = import("./src/Dto/DepId.mjs").default;
|
|
12
|
+
type TeqFw_Di_DepId$Factory = InstanceType<typeof import("./src/Dto/DepId.mjs").Factory>;
|
|
12
13
|
type TeqFw_Di_Dto_DepId = import("./src/Dto/DepId.mjs").default;
|
|
13
|
-
type TeqFw_Di_Dto_DepId$DTO = import("./src/Dto/DepId.mjs").
|
|
14
|
+
type TeqFw_Di_Dto_DepId$DTO = import("./src/Dto/DepId.mjs").default;
|
|
15
|
+
type TeqFw_Di_Dto_DepId$Factory = InstanceType<typeof import("./src/Dto/DepId.mjs").Factory>;
|
|
14
16
|
type TeqFw_Di_Dto_Resolver_Config = import("./src/Dto/Resolver/Config.mjs").default;
|
|
15
|
-
type TeqFw_Di_Dto_Resolver_Config$DTO = import("./src/Dto/Resolver/Config.mjs").
|
|
17
|
+
type TeqFw_Di_Dto_Resolver_Config$DTO = import("./src/Dto/Resolver/Config.mjs").default;
|
|
18
|
+
type TeqFw_Di_Dto_Resolver_Config$Factory = InstanceType<typeof import("./src/Dto/Resolver/Config.mjs").Factory>;
|
|
16
19
|
type TeqFw_Di_Dto_Resolver_Config_Namespace = import("./src/Dto/Resolver/Config/Namespace.mjs").default;
|
|
17
|
-
type TeqFw_Di_Dto_Resolver_Config_Namespace$DTO = import("./src/Dto/Resolver/Config/Namespace.mjs").
|
|
18
|
-
type TeqFw_Di_Dto_Resolver_Config_Namespace$
|
|
20
|
+
type TeqFw_Di_Dto_Resolver_Config_Namespace$DTO = import("./src/Dto/Resolver/Config/Namespace.mjs").default;
|
|
21
|
+
type TeqFw_Di_Dto_Resolver_Config_Namespace$Factory = InstanceType<typeof import("./src/Dto/Resolver/Config/Namespace.mjs").Factory>;
|
|
19
22
|
type TeqFw_Di_Enum_Composition = typeof import("./src/Enum/Composition.mjs").default;
|
|
20
23
|
type TeqFw_Di_Enum_Life = typeof import("./src/Enum/Life.mjs").default;
|
|
21
24
|
type TeqFw_Di_Enum_Platform = typeof import("./src/Enum/Platform.mjs").default;
|
package/jsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"checkJs": true,
|
|
5
|
-
"forceConsistentCasingInFileNames": true,
|
|
6
|
-
"module": "nodenext",
|
|
7
|
-
"moduleResolution": "nodenext",
|
|
8
|
-
"noEmit": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"target": "ESNext"
|
|
11
|
-
},
|
|
12
|
-
"include": ["src", "test", "types.d.ts"]
|
|
13
|
-
}
|