@ddd-ts/event-tree 0.0.0-eventviz.12 → 0.0.0-eventviz.13
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/edge.d.ts +4 -0
- package/dist/edge.d.ts.map +1 -1
- package/dist/engine/engine.d.ts +13 -0
- package/dist/engine/engine.d.ts.map +1 -1
- package/dist/engine/engine.mjs +34 -0
- package/package.json +2 -2
package/dist/edge.d.ts
CHANGED
package/dist/edge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAChD,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACpD,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAC3E,KAAK,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,KAAK,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,IAAI,GACZ;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,QAAQ,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,EAAE,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/engine/engine.d.ts
CHANGED
|
@@ -13,6 +13,19 @@ export declare class Engine {
|
|
|
13
13
|
private nodes;
|
|
14
14
|
saveNode(node: Node): void;
|
|
15
15
|
getNodes(): readonly Node[];
|
|
16
|
+
/**
|
|
17
|
+
* Edge targets discovered from `new X()` calls are speculative: when a walker
|
|
18
|
+
* records them it only knows the constructor name, not whether `X` is a
|
|
19
|
+
* command, an event, or something unrelated (an error, `Date`, ...). It
|
|
20
|
+
* therefore guesses a kind (e.g. command handlers assume every instantiation
|
|
21
|
+
* is an emitted event). Once every file has been walked we know the full set
|
|
22
|
+
* of commands and events, so we reconcile each command/event-targeted edge
|
|
23
|
+
* against it: keep the guess when it matches a real node, correct the kind
|
|
24
|
+
* when the target turns out to be the other kind (e.g. a command handler that
|
|
25
|
+
* dispatches another command), and drop edges that point at a class which is
|
|
26
|
+
* neither a command nor an event.
|
|
27
|
+
*/
|
|
28
|
+
private resolveEdges;
|
|
16
29
|
reset(): void;
|
|
17
30
|
run(root?: string): void;
|
|
18
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/engine/engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,KAAK,SAAS,GAAG,CACf,GAAG,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAChD,UAAU,CAAC,WAAW,CAAC,CAAC;AAE7B,qBAAa,MAAM;IACjB,OAAO,CAAC,UAAU,CAAmB;IAErC,EAAE,CAAC,MAAM,EAAE,SAAS;IAKpB,OAAO,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Y;IAiCpB,KAAK;IAKL,GAAG,CAAC,IAAI,GAAE,MAAsB;CAqBjC;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
|
package/dist/engine/engine.mjs
CHANGED
|
@@ -28,6 +28,39 @@ var Engine = class {
|
|
|
28
28
|
getNodes() {
|
|
29
29
|
return this.nodes;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Edge targets discovered from `new X()` calls are speculative: when a walker
|
|
33
|
+
* records them it only knows the constructor name, not whether `X` is a
|
|
34
|
+
* command, an event, or something unrelated (an error, `Date`, ...). It
|
|
35
|
+
* therefore guesses a kind (e.g. command handlers assume every instantiation
|
|
36
|
+
* is an emitted event). Once every file has been walked we know the full set
|
|
37
|
+
* of commands and events, so we reconcile each command/event-targeted edge
|
|
38
|
+
* against it: keep the guess when it matches a real node, correct the kind
|
|
39
|
+
* when the target turns out to be the other kind (e.g. a command handler that
|
|
40
|
+
* dispatches another command), and drop edges that point at a class which is
|
|
41
|
+
* neither a command nor an event.
|
|
42
|
+
*/
|
|
43
|
+
resolveEdges() {
|
|
44
|
+
const commands = /* @__PURE__ */ new Set();
|
|
45
|
+
const events = /* @__PURE__ */ new Set();
|
|
46
|
+
for (const node of this.nodes) if (node.type === "command") commands.add(node.name);
|
|
47
|
+
else if (node.type === "event") events.add(node.name);
|
|
48
|
+
this.edges = this.edges.flatMap((edge) => {
|
|
49
|
+
if (edge.to.type !== "command" && edge.to.type !== "event") return [edge];
|
|
50
|
+
const isCommand = commands.has(edge.to.name);
|
|
51
|
+
const isEvent = events.has(edge.to.name);
|
|
52
|
+
if (!isCommand && !isEvent) return [];
|
|
53
|
+
const resolved = edge.to.type === "command" ? isCommand ? "command" : "event" : isEvent ? "event" : "command";
|
|
54
|
+
if (resolved === edge.to.type) return [edge];
|
|
55
|
+
return [{
|
|
56
|
+
...edge,
|
|
57
|
+
to: {
|
|
58
|
+
type: resolved,
|
|
59
|
+
name: edge.to.name
|
|
60
|
+
}
|
|
61
|
+
}];
|
|
62
|
+
});
|
|
63
|
+
}
|
|
31
64
|
reset() {
|
|
32
65
|
this.edges = [];
|
|
33
66
|
this.nodes = [];
|
|
@@ -44,6 +77,7 @@ var Engine = class {
|
|
|
44
77
|
}
|
|
45
78
|
} });
|
|
46
79
|
}
|
|
80
|
+
this.resolveEdges();
|
|
47
81
|
}
|
|
48
82
|
};
|
|
49
83
|
const engine = new Engine();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts/event-tree",
|
|
3
|
-
"version": "0.0.0-eventviz.
|
|
3
|
+
"version": "0.0.0-eventviz.13",
|
|
4
4
|
"types": "dist/server/index.d.ts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"oxc-walker": "^1.0.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@ddd-ts/tools": "0.0.0-eventviz.
|
|
17
|
+
"@ddd-ts/tools": "0.0.0-eventviz.13",
|
|
18
18
|
"@types/node": "^22.14.1"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|