@statelyai/graph 0.1.0 → 0.3.1
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/README.md +65 -15
- package/dist/{adjacency-list-CXpOCibq.mjs → adjacency-list-ITO40kmn.mjs} +34 -1
- package/dist/{algorithms-R35X6ro4.mjs → algorithms-NWSB2RWj.mjs} +753 -19
- package/dist/algorithms.d.mts +488 -11
- package/dist/algorithms.mjs +2 -2
- package/dist/converter-CchokMDg.mjs +67 -0
- package/dist/edge-list-CgX6bBIF.mjs +71 -0
- package/dist/formats/adjacency-list/index.d.mts +44 -0
- package/dist/formats/adjacency-list/index.mjs +3 -0
- package/dist/formats/converter/index.d.mts +61 -0
- package/dist/formats/converter/index.mjs +3 -0
- package/dist/formats/cytoscape/index.d.mts +83 -0
- package/dist/formats/cytoscape/index.mjs +135 -0
- package/dist/formats/d3/index.d.mts +68 -0
- package/dist/formats/d3/index.mjs +111 -0
- package/dist/formats/dot/index.d.mts +63 -0
- package/dist/formats/dot/index.mjs +288 -0
- package/dist/formats/edge-list/index.d.mts +43 -0
- package/dist/formats/edge-list/index.mjs +3 -0
- package/dist/formats/gexf/index.d.mts +9 -0
- package/dist/formats/gexf/index.mjs +249 -0
- package/dist/formats/gml/index.d.mts +65 -0
- package/dist/formats/gml/index.mjs +291 -0
- package/dist/formats/graphml/index.d.mts +9 -0
- package/dist/{graphml-CUTNRXqd.mjs → formats/graphml/index.mjs} +18 -4
- package/dist/formats/jgf/index.d.mts +79 -0
- package/dist/formats/jgf/index.mjs +134 -0
- package/dist/formats/mermaid/index.d.mts +381 -0
- package/dist/formats/mermaid/index.mjs +2237 -0
- package/dist/formats/tgf/index.d.mts +54 -0
- package/dist/formats/tgf/index.mjs +111 -0
- package/dist/index.d.mts +332 -21
- package/dist/index.mjs +117 -13
- package/dist/{indexing-BHg1VhqN.mjs → indexing-eNDrXdDA.mjs} +31 -2
- package/dist/queries.d.mts +430 -9
- package/dist/queries.mjs +472 -9
- package/dist/{types-XV3S5Jnh.d.mts → types-BDXC1O5b.d.mts} +37 -2
- package/package.json +43 -17
- package/dist/adjacency-list-DW-lAUe8.d.mts +0 -10
- package/dist/dot-BRtq3e3c.mjs +0 -59
- package/dist/dot-HmJeUMsj.d.mts +0 -6
- package/dist/edge-list-BRujEnnU.mjs +0 -39
- package/dist/edge-list-CJmfoNu2.d.mts +0 -10
- package/dist/formats/adjacency-list.d.mts +0 -2
- package/dist/formats/adjacency-list.mjs +0 -3
- package/dist/formats/dot.d.mts +0 -2
- package/dist/formats/dot.mjs +0 -3
- package/dist/formats/edge-list.d.mts +0 -2
- package/dist/formats/edge-list.mjs +0 -3
- package/dist/formats/graphml.d.mts +0 -2
- package/dist/formats/graphml.mjs +0 -3
- package/dist/graphml-CMjPzSfY.d.mts +0 -7
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { c as Graph, f as GraphFormatConverter } from "../../types-BDXC1O5b.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/formats/mermaid/sequence.d.ts
|
|
4
|
+
interface SequenceNodeData {
|
|
5
|
+
actorType: 'participant' | 'actor';
|
|
6
|
+
alias?: string;
|
|
7
|
+
created?: boolean;
|
|
8
|
+
destroyed?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface SequenceEdgeData {
|
|
11
|
+
kind: 'message' | 'activation' | 'deactivation';
|
|
12
|
+
stroke?: 'solid' | 'dotted';
|
|
13
|
+
arrowType?: 'filled' | 'open' | 'cross' | 'async';
|
|
14
|
+
bidirectional?: boolean;
|
|
15
|
+
sequenceNumber?: number;
|
|
16
|
+
}
|
|
17
|
+
type SequenceBlock = {
|
|
18
|
+
type: 'loop';
|
|
19
|
+
label: string;
|
|
20
|
+
edgeIds: string[];
|
|
21
|
+
} | {
|
|
22
|
+
type: 'alt';
|
|
23
|
+
label: string;
|
|
24
|
+
branches: {
|
|
25
|
+
label?: string;
|
|
26
|
+
edgeIds: string[];
|
|
27
|
+
}[];
|
|
28
|
+
} | {
|
|
29
|
+
type: 'opt';
|
|
30
|
+
label: string;
|
|
31
|
+
edgeIds: string[];
|
|
32
|
+
} | {
|
|
33
|
+
type: 'par';
|
|
34
|
+
branches: {
|
|
35
|
+
label: string;
|
|
36
|
+
edgeIds: string[];
|
|
37
|
+
}[];
|
|
38
|
+
} | {
|
|
39
|
+
type: 'critical';
|
|
40
|
+
label: string;
|
|
41
|
+
edgeIds: string[];
|
|
42
|
+
options?: {
|
|
43
|
+
label: string;
|
|
44
|
+
edgeIds: string[];
|
|
45
|
+
}[];
|
|
46
|
+
} | {
|
|
47
|
+
type: 'break';
|
|
48
|
+
label: string;
|
|
49
|
+
edgeIds: string[];
|
|
50
|
+
} | {
|
|
51
|
+
type: 'rect';
|
|
52
|
+
color: string;
|
|
53
|
+
edgeIds: string[];
|
|
54
|
+
};
|
|
55
|
+
interface SequenceGraphData {
|
|
56
|
+
diagramType: 'sequence';
|
|
57
|
+
autonumber?: boolean;
|
|
58
|
+
blocks?: SequenceBlock[];
|
|
59
|
+
}
|
|
60
|
+
type SequenceGraph = Graph<SequenceNodeData, SequenceEdgeData, SequenceGraphData>;
|
|
61
|
+
/**
|
|
62
|
+
* Parses a Mermaid sequence diagram string into a Graph.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const graph = fromMermaidSequence(`
|
|
66
|
+
* sequenceDiagram
|
|
67
|
+
* participant Alice
|
|
68
|
+
* participant Bob
|
|
69
|
+
* Alice->>Bob: Hello
|
|
70
|
+
* Bob-->>Alice: Hi back
|
|
71
|
+
* `);
|
|
72
|
+
*/
|
|
73
|
+
declare function fromMermaidSequence(input: string): SequenceGraph;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a sequence diagram Graph to a Mermaid sequence diagram string.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const mermaid = toMermaidSequence(graph);
|
|
79
|
+
* // "sequenceDiagram\n participant Alice\n ..."
|
|
80
|
+
*/
|
|
81
|
+
declare function toMermaidSequence(graph: SequenceGraph): string;
|
|
82
|
+
/**
|
|
83
|
+
* Bidirectional converter for Mermaid sequence diagram format.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* const graph = mermaidSequenceConverter.from(`
|
|
87
|
+
* sequenceDiagram
|
|
88
|
+
* Alice->>Bob: Hello
|
|
89
|
+
* `);
|
|
90
|
+
* const str = mermaidSequenceConverter.to(graph);
|
|
91
|
+
*/
|
|
92
|
+
declare const mermaidSequenceConverter: GraphFormatConverter<string>;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/formats/mermaid/flowchart.d.ts
|
|
95
|
+
interface FlowchartNodeData {
|
|
96
|
+
classes?: string[];
|
|
97
|
+
link?: string;
|
|
98
|
+
tooltip?: string;
|
|
99
|
+
}
|
|
100
|
+
interface FlowchartEdgeData {
|
|
101
|
+
stroke: 'normal' | 'dotted' | 'thick';
|
|
102
|
+
arrowType: 'arrow' | 'none';
|
|
103
|
+
endMarker?: 'arrow' | 'circle' | 'cross';
|
|
104
|
+
startMarker?: 'arrow' | 'circle' | 'cross';
|
|
105
|
+
bidirectional?: boolean;
|
|
106
|
+
styleIndex?: number;
|
|
107
|
+
}
|
|
108
|
+
interface FlowchartGraphData {
|
|
109
|
+
diagramType: 'flowchart';
|
|
110
|
+
classDefs?: Record<string, Record<string, string>>;
|
|
111
|
+
}
|
|
112
|
+
type FlowchartGraph = Graph<FlowchartNodeData, FlowchartEdgeData, FlowchartGraphData>;
|
|
113
|
+
/**
|
|
114
|
+
* Parses a Mermaid flowchart string into a Graph.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* const graph = fromMermaidFlowchart(`
|
|
118
|
+
* flowchart TD
|
|
119
|
+
* A[Start] --> B{Decision}
|
|
120
|
+
* B -->|Yes| C[End]
|
|
121
|
+
* `);
|
|
122
|
+
*/
|
|
123
|
+
declare function fromMermaidFlowchart(input: string): FlowchartGraph;
|
|
124
|
+
/**
|
|
125
|
+
* Converts a flowchart Graph to a Mermaid flowchart string.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* const mermaid = toMermaidFlowchart(graph);
|
|
129
|
+
* // "flowchart TD\n A[Start] --> B{Decision}\n ..."
|
|
130
|
+
*/
|
|
131
|
+
declare function toMermaidFlowchart(graph: FlowchartGraph): string;
|
|
132
|
+
/**
|
|
133
|
+
* Bidirectional converter for Mermaid flowchart format.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* const graph = mermaidFlowchartConverter.from(`
|
|
137
|
+
* flowchart TD
|
|
138
|
+
* A --> B
|
|
139
|
+
* `);
|
|
140
|
+
* const str = mermaidFlowchartConverter.to(graph);
|
|
141
|
+
*/
|
|
142
|
+
declare const mermaidFlowchartConverter: GraphFormatConverter<string>;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/formats/mermaid/state.d.ts
|
|
145
|
+
interface StateNodeData {
|
|
146
|
+
description?: string;
|
|
147
|
+
stateType?: 'choice' | 'fork' | 'join';
|
|
148
|
+
notes?: Array<{
|
|
149
|
+
position: 'left' | 'right';
|
|
150
|
+
text: string;
|
|
151
|
+
}>;
|
|
152
|
+
isStart?: boolean;
|
|
153
|
+
isEnd?: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface StateEdgeData {}
|
|
156
|
+
interface StateGraphData {
|
|
157
|
+
diagramType: 'stateDiagram';
|
|
158
|
+
}
|
|
159
|
+
type StateGraph = Graph<StateNodeData, StateEdgeData, StateGraphData>;
|
|
160
|
+
/**
|
|
161
|
+
* Parses a Mermaid state diagram string into a Graph.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* const graph = fromMermaidState(`
|
|
165
|
+
* stateDiagram-v2
|
|
166
|
+
* [*] --> Idle
|
|
167
|
+
* Idle --> Running : start
|
|
168
|
+
* Running --> [*]
|
|
169
|
+
* `);
|
|
170
|
+
*/
|
|
171
|
+
declare function fromMermaidState(input: string): StateGraph;
|
|
172
|
+
/**
|
|
173
|
+
* Converts a state diagram Graph to a Mermaid state diagram string.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* const mermaid = toMermaidState(graph);
|
|
177
|
+
* // "stateDiagram-v2\n [*] --> Idle\n ..."
|
|
178
|
+
*/
|
|
179
|
+
declare function toMermaidState(graph: StateGraph): string;
|
|
180
|
+
/**
|
|
181
|
+
* Bidirectional converter for Mermaid state diagram format.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* const graph = mermaidStateConverter.from(`
|
|
185
|
+
* stateDiagram-v2
|
|
186
|
+
* [*] --> Active
|
|
187
|
+
* `);
|
|
188
|
+
* const str = mermaidStateConverter.to(graph);
|
|
189
|
+
*/
|
|
190
|
+
declare const mermaidStateConverter: GraphFormatConverter<string>;
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/formats/mermaid/class-diagram.d.ts
|
|
193
|
+
interface ClassNodeData {
|
|
194
|
+
members?: Array<{
|
|
195
|
+
visibility: '+' | '-' | '#' | '~';
|
|
196
|
+
name: string;
|
|
197
|
+
type?: string;
|
|
198
|
+
isMethod: boolean;
|
|
199
|
+
}>;
|
|
200
|
+
annotation?: string;
|
|
201
|
+
genericType?: string;
|
|
202
|
+
}
|
|
203
|
+
interface ClassEdgeData {
|
|
204
|
+
relationType: 'inheritance' | 'composition' | 'aggregation' | 'association' | 'dependency' | 'realization' | 'link' | 'dashed';
|
|
205
|
+
sourceCardinality?: string;
|
|
206
|
+
targetCardinality?: string;
|
|
207
|
+
}
|
|
208
|
+
interface ClassGraphData {
|
|
209
|
+
diagramType: 'classDiagram';
|
|
210
|
+
}
|
|
211
|
+
type ClassGraph = Graph<ClassNodeData, ClassEdgeData, ClassGraphData>;
|
|
212
|
+
/**
|
|
213
|
+
* Parses a Mermaid class diagram string into a Graph.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* const graph = fromMermaidClass(`
|
|
217
|
+
* classDiagram
|
|
218
|
+
* class Animal {
|
|
219
|
+
* +String name
|
|
220
|
+
* +eat() void
|
|
221
|
+
* }
|
|
222
|
+
* Animal <|-- Dog
|
|
223
|
+
* `);
|
|
224
|
+
*/
|
|
225
|
+
declare function fromMermaidClass(input: string): ClassGraph;
|
|
226
|
+
/**
|
|
227
|
+
* Converts a class diagram Graph to a Mermaid class diagram string.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* const mermaid = toMermaidClass(graph);
|
|
231
|
+
* // "classDiagram\n class Animal {\n ..."
|
|
232
|
+
*/
|
|
233
|
+
declare function toMermaidClass(graph: ClassGraph): string;
|
|
234
|
+
/**
|
|
235
|
+
* Bidirectional converter for Mermaid class diagram format.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* const graph = mermaidClassConverter.from(`
|
|
239
|
+
* classDiagram
|
|
240
|
+
* Animal <|-- Dog
|
|
241
|
+
* `);
|
|
242
|
+
* const str = mermaidClassConverter.to(graph);
|
|
243
|
+
*/
|
|
244
|
+
declare const mermaidClassConverter: GraphFormatConverter<string>;
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/formats/mermaid/er-diagram.d.ts
|
|
247
|
+
interface ERNodeData {
|
|
248
|
+
attributes?: Array<{
|
|
249
|
+
type: string;
|
|
250
|
+
name: string;
|
|
251
|
+
key?: 'PK' | 'FK' | 'UK';
|
|
252
|
+
comment?: string;
|
|
253
|
+
}>;
|
|
254
|
+
}
|
|
255
|
+
interface EREdgeData {
|
|
256
|
+
sourceCardinality: 'one' | 'zero-or-one' | 'zero-or-more' | 'one-or-more';
|
|
257
|
+
targetCardinality: 'one' | 'zero-or-one' | 'zero-or-more' | 'one-or-more';
|
|
258
|
+
identifying: boolean;
|
|
259
|
+
}
|
|
260
|
+
interface ERGraphData {
|
|
261
|
+
diagramType: 'erDiagram';
|
|
262
|
+
}
|
|
263
|
+
type ERGraph = Graph<ERNodeData, EREdgeData, ERGraphData>;
|
|
264
|
+
/**
|
|
265
|
+
* Parses a Mermaid ER diagram string into a Graph.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* const graph = fromMermaidER(`
|
|
269
|
+
* erDiagram
|
|
270
|
+
* CUSTOMER ||--o{ ORDER : places
|
|
271
|
+
* ORDER ||--|{ LINE_ITEM : contains
|
|
272
|
+
* `);
|
|
273
|
+
*/
|
|
274
|
+
declare function fromMermaidER(input: string): ERGraph;
|
|
275
|
+
/**
|
|
276
|
+
* Converts an ER diagram Graph to a Mermaid ER diagram string.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* const mermaid = toMermaidER(graph);
|
|
280
|
+
* // "erDiagram\n CUSTOMER ||--o{ ORDER : \"places\"\n ..."
|
|
281
|
+
*/
|
|
282
|
+
declare function toMermaidER(graph: ERGraph): string;
|
|
283
|
+
/**
|
|
284
|
+
* Bidirectional converter for Mermaid ER diagram format.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* const graph = mermaidERConverter.from(`
|
|
288
|
+
* erDiagram
|
|
289
|
+
* CUSTOMER ||--o{ ORDER : places
|
|
290
|
+
* `);
|
|
291
|
+
* const str = mermaidERConverter.to(graph);
|
|
292
|
+
*/
|
|
293
|
+
declare const mermaidERConverter: GraphFormatConverter<string>;
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/formats/mermaid/mindmap.d.ts
|
|
296
|
+
interface MindmapNodeData {
|
|
297
|
+
icon?: string;
|
|
298
|
+
}
|
|
299
|
+
interface MindmapEdgeData {}
|
|
300
|
+
interface MindmapGraphData {
|
|
301
|
+
diagramType: 'mindmap';
|
|
302
|
+
}
|
|
303
|
+
type MindmapGraph = Graph<MindmapNodeData, MindmapEdgeData, MindmapGraphData>;
|
|
304
|
+
/**
|
|
305
|
+
* Parses a Mermaid mindmap string into a Graph.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* const graph = fromMermaidMindmap(`
|
|
309
|
+
* mindmap
|
|
310
|
+
* Root
|
|
311
|
+
* Child A
|
|
312
|
+
* Grandchild
|
|
313
|
+
* Child B
|
|
314
|
+
* `);
|
|
315
|
+
*/
|
|
316
|
+
declare function fromMermaidMindmap(input: string): MindmapGraph;
|
|
317
|
+
/**
|
|
318
|
+
* Converts a mindmap Graph to a Mermaid mindmap string.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* const mermaid = toMermaidMindmap(graph);
|
|
322
|
+
* // "mindmap\n Root\n Child A\n ..."
|
|
323
|
+
*/
|
|
324
|
+
declare function toMermaidMindmap(graph: MindmapGraph): string;
|
|
325
|
+
/**
|
|
326
|
+
* Bidirectional converter for Mermaid mindmap format.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* const graph = mermaidMindmapConverter.from(`
|
|
330
|
+
* mindmap
|
|
331
|
+
* Root
|
|
332
|
+
* Branch
|
|
333
|
+
* `);
|
|
334
|
+
* const str = mermaidMindmapConverter.to(graph);
|
|
335
|
+
*/
|
|
336
|
+
declare const mermaidMindmapConverter: GraphFormatConverter<string>;
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/formats/mermaid/block.d.ts
|
|
339
|
+
interface BlockNodeData {
|
|
340
|
+
span?: number;
|
|
341
|
+
}
|
|
342
|
+
interface BlockEdgeData {}
|
|
343
|
+
interface BlockGraphData {
|
|
344
|
+
diagramType: 'block';
|
|
345
|
+
columns?: number;
|
|
346
|
+
}
|
|
347
|
+
type BlockGraph = Graph<BlockNodeData, BlockEdgeData, BlockGraphData>;
|
|
348
|
+
/**
|
|
349
|
+
* Parses a Mermaid block diagram string into a Graph.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* const graph = fromMermaidBlock(`
|
|
353
|
+
* block-beta
|
|
354
|
+
* columns 2
|
|
355
|
+
* a["Task A"] b["Task B"]
|
|
356
|
+
* a --> b
|
|
357
|
+
* `);
|
|
358
|
+
*/
|
|
359
|
+
declare function fromMermaidBlock(input: string): BlockGraph;
|
|
360
|
+
/**
|
|
361
|
+
* Converts a block diagram Graph to a Mermaid block diagram string.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* const mermaid = toMermaidBlock(graph);
|
|
365
|
+
* // "block-beta\n columns 2\n a[\"Task A\"]\n ..."
|
|
366
|
+
*/
|
|
367
|
+
declare function toMermaidBlock(graph: BlockGraph): string;
|
|
368
|
+
/**
|
|
369
|
+
* Bidirectional converter for Mermaid block diagram format.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* const graph = mermaidBlockConverter.from(`
|
|
373
|
+
* block-beta
|
|
374
|
+
* columns 2
|
|
375
|
+
* a b
|
|
376
|
+
* `);
|
|
377
|
+
* const str = mermaidBlockConverter.to(graph);
|
|
378
|
+
*/
|
|
379
|
+
declare const mermaidBlockConverter: GraphFormatConverter<string>;
|
|
380
|
+
//#endregion
|
|
381
|
+
export { type BlockEdgeData, type BlockGraphData, type BlockNodeData, type ClassEdgeData, type ClassGraphData, type ClassNodeData, type EREdgeData, type ERGraphData, type ERNodeData, type FlowchartEdgeData, type FlowchartGraphData, type FlowchartNodeData, type MindmapEdgeData, type MindmapGraphData, type MindmapNodeData, type SequenceBlock, type SequenceEdgeData, type SequenceGraphData, type SequenceNodeData, type StateEdgeData, type StateGraphData, type StateNodeData, fromMermaidBlock, fromMermaidClass, fromMermaidER, fromMermaidFlowchart, fromMermaidMindmap, fromMermaidSequence, fromMermaidState, mermaidBlockConverter, mermaidClassConverter, mermaidERConverter, mermaidFlowchartConverter, mermaidMindmapConverter, mermaidSequenceConverter, mermaidStateConverter, toMermaidBlock, toMermaidClass, toMermaidER, toMermaidFlowchart, toMermaidMindmap, toMermaidSequence, toMermaidState };
|