@statelyai/graph 0.7.0 → 0.9.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.
@@ -5,31 +5,59 @@ interface EntityRect {
5
5
  width: number;
6
6
  height: number;
7
7
  }
8
- interface GraphConfig<TNodeData = any, TEdgeData = any, TGraphData = any> {
8
+ /** Config-level base shared optional visual/style props for nodes, edges, ports. */
9
+ interface GraphEntityConfig {
10
+ x?: number;
11
+ y?: number;
12
+ width?: number;
13
+ height?: number;
14
+ style?: Record<string, string | number>;
15
+ }
16
+ /** Resolved entity base — optional visual props (non-visual graphs may omit). */
17
+ interface GraphEntity extends GraphEntityConfig {}
18
+ /** Visual entity base — required position/size. */
19
+ interface VisualGraphEntity {
20
+ x: number;
21
+ y: number;
22
+ width: number;
23
+ height: number;
24
+ style?: Record<string, string | number>;
25
+ }
26
+ type PortDirection = 'in' | 'out' | 'inout';
27
+ interface PortConfig<TPortData = any> extends GraphEntityConfig {
28
+ name: string;
29
+ direction?: PortDirection;
30
+ label?: string;
31
+ data?: TPortData;
32
+ }
33
+ interface GraphPort<TPortData = any> extends GraphEntity {
34
+ name: string;
35
+ direction: PortDirection;
36
+ label?: string;
37
+ data: TPortData;
38
+ }
39
+ interface VisualPort<TPortData = any> extends Omit<GraphPort<TPortData>, keyof EntityRect>, VisualGraphEntity {}
40
+ interface GraphConfig<TNodeData = any, TEdgeData = any, TGraphData = any, TPortData = any> {
9
41
  id?: string;
10
42
  type?: 'directed' | 'undirected';
11
43
  initialNodeId?: string;
12
- nodes?: NodeConfig<TNodeData>[];
44
+ nodes?: NodeConfig<TNodeData, TPortData>[];
13
45
  edges?: EdgeConfig<TEdgeData>[];
14
46
  data?: TGraphData;
15
47
  direction?: 'up' | 'down' | 'left' | 'right';
16
48
  style?: Record<string, string | number>;
17
49
  }
18
- interface NodeConfig<TNodeData = any> {
50
+ interface NodeConfig<TNodeData = any, TPortData = any> extends GraphEntityConfig {
19
51
  id: string;
20
52
  parentId?: string | null;
21
53
  initialNodeId?: string;
22
54
  label?: string;
23
55
  data?: TNodeData;
24
- x?: number;
25
- y?: number;
26
- width?: number;
27
- height?: number;
56
+ ports?: PortConfig<TPortData>[];
28
57
  shape?: string;
29
58
  color?: string;
30
- style?: Record<string, string | number>;
31
59
  }
32
- interface EdgeConfig<TEdgeData = any> {
60
+ interface EdgeConfig<TEdgeData = any> extends GraphEntityConfig {
33
61
  /**
34
62
  * The id of the edge.
35
63
  */
@@ -52,40 +80,35 @@ interface EdgeConfig<TEdgeData = any> {
52
80
  * When `getWeight` is not provided, algorithms default to `edge.weight ?? 1`.
53
81
  */
54
82
  weight?: number;
83
+ /** Port name on the source node this edge connects from. */
84
+ sourcePort?: string;
85
+ /** Port name on the target node this edge connects to. */
86
+ targetPort?: string;
55
87
  data?: TEdgeData;
56
- x?: number;
57
- y?: number;
58
- width?: number;
59
- height?: number;
60
88
  color?: string;
61
- style?: Record<string, string | number>;
62
89
  }
63
- interface Graph<TNodeData = any, TEdgeData = any, TGraphData = any> {
90
+ interface Graph<TNodeData = any, TEdgeData = any, TGraphData = any, TPortData = any> {
64
91
  id: string;
65
92
  type: 'directed' | 'undirected';
66
93
  initialNodeId?: string | null;
67
- nodes: GraphNode<TNodeData>[];
94
+ nodes: GraphNode<TNodeData, TPortData>[];
68
95
  edges: GraphEdge<TEdgeData>[];
69
96
  data: TGraphData;
70
97
  direction?: 'up' | 'down' | 'left' | 'right';
71
98
  style?: Record<string, string | number>;
72
99
  }
73
- interface GraphNode<TNodeData = any> {
100
+ interface GraphNode<TNodeData = any, TPortData = any> extends GraphEntity {
74
101
  type: 'node';
75
102
  id: string;
76
103
  parentId?: string | null;
77
104
  initialNodeId?: string | null;
78
105
  label?: string;
79
106
  data: TNodeData;
80
- x?: number;
81
- y?: number;
82
- width?: number;
83
- height?: number;
107
+ ports?: GraphPort<TPortData>[];
84
108
  shape?: string;
85
109
  color?: string;
86
- style?: Record<string, string | number>;
87
110
  }
88
- interface GraphEdge<TEdgeData = any> {
111
+ interface GraphEdge<TEdgeData = any> extends GraphEntity {
89
112
  type: 'edge';
90
113
  id: string;
91
114
  sourceId: string;
@@ -97,35 +120,35 @@ interface GraphEdge<TEdgeData = any> {
97
120
  * When `getWeight` is not provided, algorithms default to `edge.weight ?? 1`.
98
121
  */
99
122
  weight?: number;
123
+ /** Port name on the source node this edge connects from. */
124
+ sourcePort?: string;
125
+ /** Port name on the target node this edge connects to. */
126
+ targetPort?: string;
100
127
  data: TEdgeData;
101
- x?: number;
102
- y?: number;
103
- width?: number;
104
- height?: number;
105
128
  color?: string;
106
- style?: Record<string, string | number>;
107
129
  }
108
- interface VisualNode<TNodeData = any> extends Omit<GraphNode<TNodeData>, keyof EntityRect>, EntityRect {
130
+ interface VisualNode<TNodeData = any, TPortData = any> extends Omit<GraphNode<TNodeData, TPortData>, keyof EntityRect>, VisualGraphEntity {
109
131
  shape?: string;
132
+ ports?: VisualPort<TPortData>[];
110
133
  }
111
- interface VisualEdge<TEdgeData = any> extends Omit<GraphEdge<TEdgeData>, keyof EntityRect>, EntityRect {}
112
- interface VisualGraph<TNodeData = any, TEdgeData = any, TGraphData = any> extends Omit<Graph<TNodeData, TEdgeData, TGraphData>, 'nodes' | 'edges'> {
113
- nodes: VisualNode<TNodeData>[];
134
+ interface VisualEdge<TEdgeData = any> extends Omit<GraphEdge<TEdgeData>, keyof EntityRect>, VisualGraphEntity {}
135
+ interface VisualGraph<TNodeData = any, TEdgeData = any, TGraphData = any, TPortData = any> extends Omit<Graph<TNodeData, TEdgeData, TGraphData, TPortData>, 'nodes' | 'edges'> {
136
+ nodes: VisualNode<TNodeData, TPortData>[];
114
137
  edges: VisualEdge<TEdgeData>[];
115
138
  direction: 'up' | 'down' | 'left' | 'right';
116
139
  }
117
- interface VisualGraphConfig<TNodeData = any, TEdgeData = any, TGraphData = any> extends GraphConfig<TNodeData, TEdgeData, TGraphData> {
140
+ interface VisualGraphConfig<TNodeData = any, TEdgeData = any, TGraphData = any, TPortData = any> extends GraphConfig<TNodeData, TEdgeData, TGraphData, TPortData> {
118
141
  direction?: 'up' | 'down' | 'left' | 'right';
119
142
  }
120
143
  interface DeleteNodeOptions {
121
144
  reparent?: boolean;
122
145
  }
123
- interface EntitiesConfig<TNodeData = any, TEdgeData = any> {
124
- nodes?: NodeConfig<TNodeData>[];
146
+ interface EntitiesConfig<TNodeData = any, TEdgeData = any, TPortData = any> {
147
+ nodes?: NodeConfig<TNodeData, TPortData>[];
125
148
  edges?: EdgeConfig<TEdgeData>[];
126
149
  }
127
- interface EntitiesUpdate<TNodeData = any, TEdgeData = any> {
128
- nodes?: (Partial<Omit<NodeConfig<TNodeData>, 'id'>> & {
150
+ interface EntitiesUpdate<TNodeData = any, TEdgeData = any, TPortData = any> {
151
+ nodes?: (Partial<Omit<NodeConfig<TNodeData, TPortData>, 'id'>> & {
129
152
  id: string;
130
153
  })[];
131
154
  edges?: (Partial<Omit<EdgeConfig<TEdgeData>, 'id'>> & {
@@ -314,4 +337,4 @@ interface TransitionOptions<TState, TEvent> {
314
337
  id?: string;
315
338
  }
316
339
  //#endregion
317
- export { VisualNode as A, SinglePathOptions as C, VisualGraph as D, VisualEdge as E, WalkOptions as M, WeightedWalkOptions as N, VisualGraphConfig as O, PathOptions as S, TraversalOptions as T, GraphPath as _, EdgeChange as a, NodeChange as b, EntitiesUpdate as c, GraphConfig as d, GraphDiff as f, GraphPatch as g, GraphNode as h, DeleteNodeOptions as i, WalkContext as j, VisualGraphFormatConverter as k, EntityRect as l, GraphFormatConverter as m, AllPairsShortestPathsOptions as n, EdgeConfig as o, GraphEdge as p, CoverageStats as r, EntitiesConfig as s, AStarOptions as t, Graph as u, GraphStep as v, TransitionOptions as w, NodeConfig as x, MSTOptions as y };
340
+ export { TraversalOptions as A, WeightedWalkOptions as B, NodeChange as C, PortDirection as D, PortConfig as E, VisualGraphFormatConverter as F, VisualNode as I, VisualPort as L, VisualGraph as M, VisualGraphConfig as N, SinglePathOptions as O, VisualGraphEntity as P, WalkContext as R, MSTOptions as S, PathOptions as T, GraphNode as _, EdgeChange as a, GraphPort as b, EntitiesUpdate as c, GraphConfig as d, GraphDiff as f, GraphFormatConverter as g, GraphEntityConfig as h, DeleteNodeOptions as i, VisualEdge as j, TransitionOptions as k, EntityRect as l, GraphEntity as m, AllPairsShortestPathsOptions as n, EdgeConfig as o, GraphEdge as p, CoverageStats as r, EntitiesConfig as s, AStarOptions as t, Graph as u, GraphPatch as v, NodeConfig as w, GraphStep as x, GraphPath as y, WalkOptions as z };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@statelyai/graph",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.9.0",
5
5
  "description": "A TypeScript-first graph library with plain JSON-serializable objects",
6
6
  "author": "David Khourshid <david@stately.ai>",
7
7
  "license": "MIT",
@@ -50,6 +50,7 @@
50
50
  "schemas"
51
51
  ],
52
52
  "devDependencies": {
53
+ "publint": "^0.3.15",
53
54
  "@changesets/changelog-github": "^0.5.2",
54
55
  "@changesets/cli": "^2.29.8",
55
56
  "@types/d3-array": "^3.2.2",
@@ -103,6 +104,8 @@
103
104
  "dev": "tsdown --watch",
104
105
  "test": "vitest",
105
106
  "typecheck": "tsc --noEmit",
107
+ "verify": "pnpm typecheck && pnpm test -- --run && pnpm build && pnpm validate:package",
108
+ "validate:package": "publint && tsx scripts/smoke-package.ts",
106
109
  "generate-schema": "tsx scripts/generate-json-schema.ts",
107
110
  "changeset": "changeset",
108
111
  "version": "changeset version",