- Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathdependencyGraph.ts
27 lines (24 loc) · 751 Bytes
/
dependencyGraph.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
import{LookerNodeSDK}from'@looker/sdk-node';
import{renderDot}from'render-dot';
import*asfsfrom'fs';
constsdk=LookerNodeSDK.init40();
// returns an svg file with the pdt dependency graph viz
constgetPDTGraph=async(modelname: string,filename: string)=>{
if(modelname){
constres=awaitsdk.ok(
sdk.graph_derived_tables_for_model({model: modelname})
);
constresult=awaitrenderDot({
input: res.graph_text,
format: 'svg',
});
constfile=fs.writeFileSync(filename,result,'binary');
returnfile;
}else{
throwError(
`Model name not specified, please specifiy a model name to pull pdt dependency graph for.`
);
}
};
// Example
//getPDTGraph('pdtgraph')