-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
index.d.ts
112 lines (83 loc) · 2.72 KB
/
index.d.ts
1
2
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
103
104
105
106
107
108
109
110
111
112
// Type definitions for graphviz 0.0
// Project: https://github.com/glejeune/node-graphviz
// Definitions by: Matt Frantz <https://github.com/mhfrantz>,
// Kamontat Chantrachirathumrong <https://github.com/kamontat>
// Kirill Ivanov <https://github.com/koorya>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export type PossibleValue = string | number | boolean;
export type RenderType = string;
export type RenderEngine = "dot" | "neato" | "circo" | "fdp" | "osage" | "twopi";
export interface Options {
[key: string]: PossibleValue;
}
export interface HasAttributes {
set(name: string, value: PossibleValue): void;
get(name: string): PossibleValue;
}
export interface Node extends HasAttributes {
readonly id: string;
}
/* tslint:disable-next-line:no-empty-interface */
export interface Edge extends HasAttributes {}
export interface OutputCallback {
(data: Buffer): void;
}
export interface ErrorCallback {
(code: number, stdout: string, stderr: string): void;
}
export interface RenderOptions {
/**
* graphviz output file type
*/
type: RenderType;
/**
* Graphviz command to use
* @default dot
*/
use?: RenderEngine | undefined;
/**
* Graphviz path
* @default $PATH
*/
path?: string | undefined;
/**
* graph options
*/
G?: Options | undefined;
/**
* node options
*/
N?: Options | undefined;
/**
* edge options
*/
E?: Options | undefined;
}
export interface Graph extends HasAttributes {
use: RenderEngine;
addNode(id: string, attrs?: any): Node;
getNode(id: string): Node;
nodeCount(): number;
addEdge(nodeOne: string | Node, nodeTwo: string | Node, attrs?: Options): Edge;
// Subgraph (cluster) API
addCluster(id: string): Graph;
getCluster(id: string): Graph;
clusterCount(): number;
setNodeAttribut(name: string, value: any): void;
getNodeAttribut(name: string): any;
setEdgeAttribut(name: string, value: any): void;
getEdgeAttribut(name: string): any;
// Path containing Graphviz binaries.
setGraphVizPath(directoryPath: string): void;
render(type_options: string | RenderOptions, filename_callback: string | OutputCallback, errback?: ErrorCallback): void;
output(type_options: string | RenderOptions, filename_callback: string | OutputCallback, errback?: ErrorCallback): void;
edgeCount(): number;
to_dot(): string;
}
export function graph(id: string): Graph;
export function digraph(id: string): Graph;
export interface ParseCallback {
(graph: Graph): void;
}
export function parse(path: string, callback: ParseCallback, errback?: ErrorCallback): void;