composed-di 0.0.5-alpha → 0.1.6
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/serviceKey.d.ts +1 -1
- package/dist/serviceKey.d.ts.map +1 -1
- package/dist/serviceModule.d.ts +15 -3
- package/dist/serviceModule.d.ts.map +1 -1
- package/dist/serviceModule.js +23 -13
- package/dist/serviceModule.js.map +1 -1
- package/dist/test-from.d.ts +2 -0
- package/dist/test-from.d.ts.map +1 -0
- package/dist/test-from.js +68 -0
- package/dist/test-from.js.map +1 -0
- package/dist/utils.d.ts +12 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +16 -8
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/ServiceKey.ts +1 -1
- package/src/ServiceModule.ts +104 -102
- package/src/utils.ts +19 -8
package/dist/serviceKey.d.ts
CHANGED
package/dist/serviceKey.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceKey.d.ts","sourceRoot":"","sources":["../src/ServiceKey.ts"],"names":[],"mappings":"AACA,qBAAa,UAAU,CAAC,CAAC;aAGK,IAAI,EAAE,MAAM;IAFxC,
|
|
1
|
+
{"version":3,"file":"ServiceKey.d.ts","sourceRoot":"","sources":["../src/ServiceKey.ts"],"names":[],"mappings":"AACA,qBAAa,UAAU,CAAC,CAAC;aAGK,IAAI,EAAE,MAAM;IAFxC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEH,IAAI,EAAE,MAAM;CAGzC"}
|
package/dist/serviceModule.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { ServiceKey } from './ServiceKey';
|
|
2
2
|
import { ServiceFactory } from './ServiceFactory';
|
|
3
|
+
type GenericFactory = ServiceFactory<unknown, readonly ServiceKey<unknown>[]>;
|
|
3
4
|
export declare class ServiceModule {
|
|
4
|
-
readonly factories:
|
|
5
|
-
constructor(
|
|
5
|
+
readonly factories: GenericFactory[];
|
|
6
|
+
private constructor();
|
|
6
7
|
get<T>(key: ServiceKey<T>): Promise<T>;
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new ServiceModule instance by aggregating and deduplicating a list of
|
|
10
|
+
* ServiceModule or GenericFactory instances.
|
|
11
|
+
* If multiple factories provide the same
|
|
12
|
+
* ServiceKey, the last one in the list takes precedence.
|
|
13
|
+
*
|
|
14
|
+
* @param {Array<ServiceModule | GenericFactory>} entries - An array of ServiceModule or GenericFactory
|
|
15
|
+
* instances to be processed into a single ServiceModule.
|
|
16
|
+
* @return {ServiceModule} A new ServiceModule containing the deduplicated factories.
|
|
17
|
+
*/
|
|
18
|
+
static from(entries: (ServiceModule | GenericFactory)[]): ServiceModule;
|
|
8
19
|
}
|
|
20
|
+
export {};
|
|
9
21
|
//# sourceMappingURL=ServiceModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceModule.d.ts","sourceRoot":"","sources":["../src/ServiceModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,
|
|
1
|
+
{"version":3,"file":"ServiceModule.d.ts","sourceRoot":"","sources":["../src/ServiceModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,KAAK,cAAc,GAAG,cAAc,CAAC,OAAO,EAAE,SAAS,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAG9E,qBAAa,aAAa;IACJ,QAAQ,CAAC,SAAS,EAAE,cAAc,EAAE;IAAxD,OAAO;IAOM,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAqBnD;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,cAAc,CAAC,EAAE,GAAG,aAAa;CAcxE"}
|
package/dist/serviceModule.js
CHANGED
|
@@ -12,9 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ServiceModule = void 0;
|
|
13
13
|
class ServiceModule {
|
|
14
14
|
constructor(factories) {
|
|
15
|
-
this.factories =
|
|
16
|
-
|
|
17
|
-
this.factories.forEach((factory) => {
|
|
15
|
+
this.factories = factories;
|
|
16
|
+
factories.forEach((factory) => {
|
|
18
17
|
checkRecursiveDependencies(factory);
|
|
19
18
|
checkMissingDependencies(factory, this.factories);
|
|
20
19
|
});
|
|
@@ -36,15 +35,25 @@ class ServiceModule {
|
|
|
36
35
|
return factory.initialize(...dependencies);
|
|
37
36
|
});
|
|
38
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new ServiceModule instance by aggregating and deduplicating a list of
|
|
40
|
+
* ServiceModule or GenericFactory instances.
|
|
41
|
+
* If multiple factories provide the same
|
|
42
|
+
* ServiceKey, the last one in the list takes precedence.
|
|
43
|
+
*
|
|
44
|
+
* @param {Array<ServiceModule | GenericFactory>} entries - An array of ServiceModule or GenericFactory
|
|
45
|
+
* instances to be processed into a single ServiceModule.
|
|
46
|
+
* @return {ServiceModule} A new ServiceModule containing the deduplicated factories.
|
|
47
|
+
*/
|
|
39
48
|
static from(entries) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
// Flatten entries and keep only the last factory for each ServiceKey
|
|
50
|
+
const flattened = entries.flatMap((e) => e instanceof ServiceModule ? e.factories : [e]);
|
|
51
|
+
const byKey = new Map();
|
|
52
|
+
// Later factories overwrite earlier ones (last-wins)
|
|
53
|
+
for (const f of flattened) {
|
|
54
|
+
byKey.set(f.provides.symbol, f);
|
|
55
|
+
}
|
|
56
|
+
return new ServiceModule(Array.from(byKey.values()));
|
|
48
57
|
}
|
|
49
58
|
}
|
|
50
59
|
exports.ServiceModule = ServiceModule;
|
|
@@ -69,9 +78,10 @@ function checkMissingDependencies(factory, factories) {
|
|
|
69
78
|
throw new Error(`${factory.provides.name} will fail because it depends on:\n ${dependencyList}`);
|
|
70
79
|
}
|
|
71
80
|
function isRegistered(key, factories) {
|
|
72
|
-
return factories.some((factory) => factory.provides === key);
|
|
81
|
+
return factories.some((factory) => { var _a; return ((_a = factory.provides) === null || _a === void 0 ? void 0 : _a.symbol) === (key === null || key === void 0 ? void 0 : key.symbol); });
|
|
73
82
|
}
|
|
74
83
|
function isSuitable(key, factory) {
|
|
75
|
-
|
|
84
|
+
var _a;
|
|
85
|
+
return ((_a = factory === null || factory === void 0 ? void 0 : factory.provides) === null || _a === void 0 ? void 0 : _a.symbol) === (key === null || key === void 0 ? void 0 : key.symbol);
|
|
76
86
|
}
|
|
77
87
|
//# sourceMappingURL=ServiceModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceModule.js","sourceRoot":"","sources":["../src/ServiceModule.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ServiceModule.js","sourceRoot":"","sources":["../src/ServiceModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,MAAa,aAAa;IACxB,YAA6B,SAA2B;QAA3B,cAAS,GAAT,SAAS,CAAkB;QACtD,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,0BAA0B,CAAC,OAAO,CAAC,CAAC;YACpC,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IAEY,GAAG,CAAI,GAAkB;;YACpC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAuB,EAAE,EAAE;gBAC9D,OAAO,UAA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
|
|
|
1
|
+
{"version":3,"file":"test-from.d.ts","sourceRoot":"","sources":["../src/test-from.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const ServiceKey_1 = require("./ServiceKey");
|
|
13
|
+
const ServiceFactory_1 = require("./ServiceFactory");
|
|
14
|
+
const ServiceModule_1 = require("./ServiceModule");
|
|
15
|
+
function testLastWinsFlat() {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const Key = new ServiceKey_1.ServiceKey('Value');
|
|
18
|
+
const first = ServiceFactory_1.ServiceFactory.oneShot({
|
|
19
|
+
provides: Key,
|
|
20
|
+
dependsOn: [],
|
|
21
|
+
initialize: () => 1,
|
|
22
|
+
});
|
|
23
|
+
const second = ServiceFactory_1.ServiceFactory.oneShot({
|
|
24
|
+
provides: Key,
|
|
25
|
+
dependsOn: [],
|
|
26
|
+
initialize: () => 2,
|
|
27
|
+
});
|
|
28
|
+
const mod = ServiceModule_1.ServiceModule.from([first, second]);
|
|
29
|
+
const value = yield mod.get(Key);
|
|
30
|
+
if (value !== 2) {
|
|
31
|
+
throw new Error(`Flat last-wins failed: expected 2, got ${value}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function testLastWinsNested() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const Key = new ServiceKey_1.ServiceKey('Value');
|
|
38
|
+
const first = ServiceFactory_1.ServiceFactory.oneShot({
|
|
39
|
+
provides: Key,
|
|
40
|
+
dependsOn: [],
|
|
41
|
+
initialize: () => 10,
|
|
42
|
+
});
|
|
43
|
+
const second = ServiceFactory_1.ServiceFactory.oneShot({
|
|
44
|
+
provides: Key,
|
|
45
|
+
dependsOn: [],
|
|
46
|
+
initialize: () => 20,
|
|
47
|
+
});
|
|
48
|
+
const a = ServiceModule_1.ServiceModule.from([first]);
|
|
49
|
+
const b = ServiceModule_1.ServiceModule.from([second]);
|
|
50
|
+
const root = ServiceModule_1.ServiceModule.from([a, b]);
|
|
51
|
+
const value = yield root.get(Key);
|
|
52
|
+
if (value !== 20) {
|
|
53
|
+
throw new Error(`Nested last-wins failed: expected 20, got ${value}`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function run() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
yield testLastWinsFlat();
|
|
60
|
+
yield testLastWinsNested();
|
|
61
|
+
console.log('All tests passed for ServiceModule.from last-wins behavior.');
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
run().catch((err) => {
|
|
65
|
+
console.error(err);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=test-from.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-from.js","sourceRoot":"","sources":["../src/test-from.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6CAA0C;AAC1C,qDAAkD;AAClD,mDAAgD;AAEhD,SAAe,gBAAgB;;QAC7B,MAAM,GAAG,GAAG,IAAI,uBAAU,CAAS,OAAO,CAAC,CAAC;QAE5C,MAAM,KAAK,GAAG,+BAAc,CAAC,OAAO,CA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AAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,6CAA6C,KAAK,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;CAAA;AAED,SAAe,GAAG;;QAChB,MAAM,gBAAgB,EAAE,CAAC;QACzB,MAAM,kBAAkB,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;IAC7E,CAAC;CAAA;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAClB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -17,10 +17,18 @@ export interface DotGraphOptions {
|
|
|
17
17
|
*
|
|
18
18
|
* Arrows point from dependencies to dependents (from what is needed to what needs it).
|
|
19
19
|
*
|
|
20
|
-
* @param module - The ServiceModule to convert to DOT notation
|
|
21
|
-
* @param options - Optional configuration for the graph appearance
|
|
22
|
-
* @returns A string containing the DOT notation graph
|
|
20
|
+
* @param {ServiceModule} module - The ServiceModule to convert to DOT notation
|
|
21
|
+
* @param {DotGraphOptions} options - Optional configuration for the graph appearance
|
|
22
|
+
* @returns {string} A string containing the DOT notation graph
|
|
23
23
|
*/
|
|
24
24
|
export declare function createDotGraph(module: ServiceModule, { direction, title, highlightLeaves, highlightRoots }?: DotGraphOptions): string;
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Prints a DOT representation of a service module graph to the console.
|
|
27
|
+
* The output can be used to visualize the graph using online graph visualization tools.
|
|
28
|
+
*
|
|
29
|
+
* @param {ServiceModule} module - The service module representing the graph to be converted into DOT format.
|
|
30
|
+
* @param {DotGraphOptions} [options] - Optional configurations to customize the output of the DOT graph.
|
|
31
|
+
* @return {void} - This function does not return a value.
|
|
32
|
+
*/
|
|
33
|
+
export declare function printDotGraph(module: ServiceModule, options?: DotGraphOptions): void;
|
|
26
34
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,eAAe;IAC9B,kGAAkG;IAClG,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACtC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yDAAyD;IACzD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AASD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,EACrB,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,GAAE,eAKtD,GACA,MAAM,CA6FR;AAED,wBAAgB,aAAa,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,eAAe;IAC9B,kGAAkG;IAClG,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACtC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yDAAyD;IACzD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AASD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,EACrB,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,GAAE,eAKtD,GACA,MAAM,CA6FR;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,eAAe,GACxB,IAAI,CAIN"}
|
package/dist/utils.js
CHANGED
|
@@ -16,12 +16,12 @@ function escapeDotString(str) {
|
|
|
16
16
|
*
|
|
17
17
|
* Arrows point from dependencies to dependents (from what is needed to what needs it).
|
|
18
18
|
*
|
|
19
|
-
* @param module - The ServiceModule to convert to DOT notation
|
|
20
|
-
* @param options - Optional configuration for the graph appearance
|
|
21
|
-
* @returns A string containing the DOT notation graph
|
|
19
|
+
* @param {ServiceModule} module - The ServiceModule to convert to DOT notation
|
|
20
|
+
* @param {DotGraphOptions} options - Optional configuration for the graph appearance
|
|
21
|
+
* @returns {string} A string containing the DOT notation graph
|
|
22
22
|
*/
|
|
23
23
|
function createDotGraph(module, { direction, title, highlightLeaves, highlightRoots } = {
|
|
24
|
-
direction: '
|
|
24
|
+
direction: 'TB',
|
|
25
25
|
title: 'Service Dependency Graph',
|
|
26
26
|
highlightLeaves: true,
|
|
27
27
|
highlightRoots: true,
|
|
@@ -90,8 +90,8 @@ function createDotGraph(module, { direction, title, highlightLeaves, highlightRo
|
|
|
90
90
|
const depName = dependency.name;
|
|
91
91
|
const depNodeId = nodeIds.get(depName);
|
|
92
92
|
if (depNodeId) {
|
|
93
|
-
// Arrow points from
|
|
94
|
-
lines.push(` ${
|
|
93
|
+
// Arrow points from dependent to dependency (what needs it -> what provides it)
|
|
94
|
+
lines.push(` ${serviceNodeId} -> ${depNodeId};`);
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
});
|
|
@@ -99,8 +99,16 @@ function createDotGraph(module, { direction, title, highlightLeaves, highlightRo
|
|
|
99
99
|
lines.push('}');
|
|
100
100
|
return lines.join('\n');
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Prints a DOT representation of a service module graph to the console.
|
|
104
|
+
* The output can be used to visualize the graph using online graph visualization tools.
|
|
105
|
+
*
|
|
106
|
+
* @param {ServiceModule} module - The service module representing the graph to be converted into DOT format.
|
|
107
|
+
* @param {DotGraphOptions} [options] - Optional configurations to customize the output of the DOT graph.
|
|
108
|
+
* @return {void} - This function does not return a value.
|
|
109
|
+
*/
|
|
110
|
+
function printDotGraph(module, options) {
|
|
111
|
+
console.log(createDotGraph(module, options));
|
|
104
112
|
console.log('\n\nCopy the DOT output above and paste it into:');
|
|
105
113
|
console.log('https://dreampuf.github.io/GraphvizOnline/');
|
|
106
114
|
}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAiCA,wCAqGC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAiCA,wCAqGC;AAUD,sCAOC;AAzID;;GAEG;AACH,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,cAAc,CAC5B,MAAqB,EACrB,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,KAAsB;IACvE,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,0BAA0B;IACjC,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;CACrB;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,oBAAoB;IACpB,KAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC5C,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MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC1C,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;QAEhD,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,UAA+B,EAAE,EAAE;YAC5D,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC;YAChC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEvC,IAAI,SAAS,EAAE,CAAC;gBACd,gFAAgF;gBAChF,KAAK,CAAC,IAAI,CAAC,KAAK,aAAa,OAAO,SAAS,GAAG,CAAC,CAAC;YACpD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,oBAAoB;IACpB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEhB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,aAAa,CAC3B,MAAqB,EACrB,OAAyB;IAEzB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;AAC5D,CAAC"}
|
package/package.json
CHANGED
package/src/ServiceKey.ts
CHANGED
package/src/ServiceModule.ts
CHANGED
|
@@ -1,102 +1,104 @@
|
|
|
1
|
-
import { ServiceKey } from './ServiceKey';
|
|
2
|
-
import { ServiceFactory } from './ServiceFactory';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
1
|
+
import { ServiceKey } from './ServiceKey';
|
|
2
|
+
import { ServiceFactory } from './ServiceFactory';
|
|
3
|
+
|
|
4
|
+
type GenericFactory = ServiceFactory<unknown, readonly ServiceKey<unknown>[]>;
|
|
5
|
+
type GenericKey = ServiceKey<unknown>;
|
|
6
|
+
|
|
7
|
+
export class ServiceModule {
|
|
8
|
+
private constructor(readonly factories: GenericFactory[]) {
|
|
9
|
+
factories.forEach((factory) => {
|
|
10
|
+
checkRecursiveDependencies(factory);
|
|
11
|
+
checkMissingDependencies(factory, this.factories);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async get<T>(key: ServiceKey<T>): Promise<T> {
|
|
16
|
+
const factory = this.factories.find((factory: GenericFactory) => {
|
|
17
|
+
return isSuitable(key, factory);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Check if a factory to supply the requested key was not found
|
|
21
|
+
if (!factory) {
|
|
22
|
+
throw new Error(`Could not find a suitable factory for ${key.name}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Resolve all dependencies first
|
|
26
|
+
const dependencies = await Promise.all(
|
|
27
|
+
factory.dependsOn.map((dependencyKey: ServiceKey<unknown>) => {
|
|
28
|
+
return this.get(dependencyKey);
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Call the factory to retrieve the dependency
|
|
33
|
+
return factory.initialize(...dependencies);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new ServiceModule instance by aggregating and deduplicating a list of
|
|
38
|
+
* ServiceModule or GenericFactory instances.
|
|
39
|
+
* If multiple factories provide the same
|
|
40
|
+
* ServiceKey, the last one in the list takes precedence.
|
|
41
|
+
*
|
|
42
|
+
* @param {Array<ServiceModule | GenericFactory>} entries - An array of ServiceModule or GenericFactory
|
|
43
|
+
* instances to be processed into a single ServiceModule.
|
|
44
|
+
* @return {ServiceModule} A new ServiceModule containing the deduplicated factories.
|
|
45
|
+
*/
|
|
46
|
+
static from(entries: (ServiceModule | GenericFactory)[]): ServiceModule {
|
|
47
|
+
// Flatten entries and keep only the last factory for each ServiceKey
|
|
48
|
+
const flattened = entries.flatMap((e) =>
|
|
49
|
+
e instanceof ServiceModule ? e.factories : [e],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const byKey = new Map<symbol, GenericFactory>();
|
|
53
|
+
// Later factories overwrite earlier ones (last-wins)
|
|
54
|
+
for (const f of flattened) {
|
|
55
|
+
byKey.set(f.provides.symbol, f);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return new ServiceModule(Array.from(byKey.values()));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function checkRecursiveDependencies(factory: GenericFactory) {
|
|
63
|
+
const recursive = factory.dependsOn.some((dependencyKey) => {
|
|
64
|
+
return dependencyKey === factory.provides;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (recursive) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
'Recursive dependency detected on: ' + factory.provides.name,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function checkMissingDependencies(
|
|
75
|
+
factory: GenericFactory,
|
|
76
|
+
factories: GenericFactory[],
|
|
77
|
+
) {
|
|
78
|
+
const missingDependencies = factory.dependsOn.filter(
|
|
79
|
+
(dependencyKey: GenericKey) => {
|
|
80
|
+
return !isRegistered(dependencyKey, factories);
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
if (missingDependencies.length === 0) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const dependencyList = missingDependencies
|
|
88
|
+
.map((dependencyKey) => ` -> ${dependencyKey.name}`)
|
|
89
|
+
.join('\n');
|
|
90
|
+
throw new Error(
|
|
91
|
+
`${factory.provides.name} will fail because it depends on:\n ${dependencyList}`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isRegistered(key: GenericKey, factories: GenericFactory[]) {
|
|
96
|
+
return factories.some((factory) => factory.provides?.symbol === key?.symbol);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function isSuitable<T, D extends readonly ServiceKey<any>[]>(
|
|
100
|
+
key: ServiceKey<T>,
|
|
101
|
+
factory: ServiceFactory<any, D>,
|
|
102
|
+
): factory is ServiceFactory<T, D> {
|
|
103
|
+
return factory?.provides?.symbol === key?.symbol;
|
|
104
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -27,14 +27,14 @@ function escapeDotString(str: string): string {
|
|
|
27
27
|
*
|
|
28
28
|
* Arrows point from dependencies to dependents (from what is needed to what needs it).
|
|
29
29
|
*
|
|
30
|
-
* @param module - The ServiceModule to convert to DOT notation
|
|
31
|
-
* @param options - Optional configuration for the graph appearance
|
|
32
|
-
* @returns A string containing the DOT notation graph
|
|
30
|
+
* @param {ServiceModule} module - The ServiceModule to convert to DOT notation
|
|
31
|
+
* @param {DotGraphOptions} options - Optional configuration for the graph appearance
|
|
32
|
+
* @returns {string} A string containing the DOT notation graph
|
|
33
33
|
*/
|
|
34
34
|
export function createDotGraph(
|
|
35
35
|
module: ServiceModule,
|
|
36
36
|
{ direction, title, highlightLeaves, highlightRoots }: DotGraphOptions = {
|
|
37
|
-
direction: '
|
|
37
|
+
direction: 'TB',
|
|
38
38
|
title: 'Service Dependency Graph',
|
|
39
39
|
highlightLeaves: true,
|
|
40
40
|
highlightRoots: true,
|
|
@@ -122,8 +122,8 @@ export function createDotGraph(
|
|
|
122
122
|
const depNodeId = nodeIds.get(depName);
|
|
123
123
|
|
|
124
124
|
if (depNodeId) {
|
|
125
|
-
// Arrow points from
|
|
126
|
-
lines.push(` ${
|
|
125
|
+
// Arrow points from dependent to dependency (what needs it -> what provides it)
|
|
126
|
+
lines.push(` ${serviceNodeId} -> ${depNodeId};`);
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
});
|
|
@@ -134,8 +134,19 @@ export function createDotGraph(
|
|
|
134
134
|
return lines.join('\n');
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Prints a DOT representation of a service module graph to the console.
|
|
139
|
+
* The output can be used to visualize the graph using online graph visualization tools.
|
|
140
|
+
*
|
|
141
|
+
* @param {ServiceModule} module - The service module representing the graph to be converted into DOT format.
|
|
142
|
+
* @param {DotGraphOptions} [options] - Optional configurations to customize the output of the DOT graph.
|
|
143
|
+
* @return {void} - This function does not return a value.
|
|
144
|
+
*/
|
|
145
|
+
export function printDotGraph(
|
|
146
|
+
module: ServiceModule,
|
|
147
|
+
options?: DotGraphOptions,
|
|
148
|
+
): void {
|
|
149
|
+
console.log(createDotGraph(module, options));
|
|
139
150
|
console.log('\n\nCopy the DOT output above and paste it into:');
|
|
140
151
|
console.log('https://dreampuf.github.io/GraphvizOnline/');
|
|
141
152
|
}
|