@ddd-ts/event-tree 0.0.0-eventviz.12 → 0.0.0-eventviz.14

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 CHANGED
@@ -34,6 +34,10 @@ export type Edge = {
34
34
  from: CommandRef;
35
35
  to: EventRef;
36
36
  source: Source;
37
+ } | {
38
+ from: CommandRef;
39
+ to: CommandRef;
40
+ source: Source;
37
41
  };
38
42
  export {};
39
43
  //# sourceMappingURL=edge.d.ts.map
@@ -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,CAAC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,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -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,CAAC,WAAW,CAIjB;IACF,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;IAKpD,OAAO,CAAC,KAAK,CAAc;IAC3B,QAAQ,CAAC,IAAI,EAAE,IAAI;IAGnB,QAAQ,IAAI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es;
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.12",
3
+ "version": "0.0.0-eventviz.14",
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.12",
17
+ "@ddd-ts/tools": "0.0.0-eventviz.14",
18
18
  "@types/node": "^22.14.1"
19
19
  },
20
20
  "exports": {