From de89e5044d1a2500505a9269bcec7709aa1dcdf4 Mon Sep 17 00:00:00 2001 From: Yuki Yamazaki <35218186+kamiazya@users.noreply.github.com> Date: Thu, 16 Feb 2023 09:18:59 +0900 Subject: [PATCH] upgrade ts-graphviz to v1 (#2395) --- .changeset/selfish-files-raise.md | 6 ++++++ package-lock.json | 16 +++++++++++----- query-graphs-js/package.json | 2 +- query-graphs-js/src/graphviz.ts | 20 ++++++++++---------- 4 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 .changeset/selfish-files-raise.md diff --git a/.changeset/selfish-files-raise.md b/.changeset/selfish-files-raise.md new file mode 100644 index 000000000..9d6eba4c9 --- /dev/null +++ b/.changeset/selfish-files-raise.md @@ -0,0 +1,6 @@ +--- +"@apollo/query-graphs": patch +--- + +Update ts-graphviz dependency + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 64a86ca35..bfcc89ed7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15830,8 +15830,12 @@ "license": "MIT" }, "node_modules/ts-graphviz": { - "version": "0.16.0", - "license": "MIT", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/ts-graphviz/-/ts-graphviz-1.5.4.tgz", + "integrity": "sha512-oxhI6wfPQBJC8WSiP0AjDI8z+9hcc9yl1etaynQJmQ2Yivn0KlT0oImLzJct7Es0TR/6xphzvJBAhGzgOjTGmQ==", + "engines": { + "node": ">=14.16" + }, "funding": { "type": "github", "url": "https://github.com/sponsors/kamiazya" @@ -16834,7 +16838,7 @@ "@apollo/federation-internals": "2.3.2", "@types/uuid": "^8.3.4", "deep-equal": "^2.0.5", - "ts-graphviz": "^0.16.0", + "ts-graphviz": "^1.5.4", "uuid": "^9.0.0" }, "engines": { @@ -17108,7 +17112,7 @@ "@apollo/federation-internals": "2.3.2", "@types/uuid": "^8.3.4", "deep-equal": "^2.0.5", - "ts-graphviz": "^0.16.0", + "ts-graphviz": "^1.5.4", "uuid": "^9.0.0" }, "dependencies": { @@ -28170,7 +28174,9 @@ "dev": true }, "ts-graphviz": { - "version": "0.16.0" + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/ts-graphviz/-/ts-graphviz-1.5.4.tgz", + "integrity": "sha512-oxhI6wfPQBJC8WSiP0AjDI8z+9hcc9yl1etaynQJmQ2Yivn0KlT0oImLzJct7Es0TR/6xphzvJBAhGzgOjTGmQ==" }, "ts-invariant": { "version": "0.10.3", diff --git a/query-graphs-js/package.json b/query-graphs-js/package.json index 738e524aa..ddedc0058 100644 --- a/query-graphs-js/package.json +++ b/query-graphs-js/package.json @@ -26,7 +26,7 @@ "@apollo/federation-internals": "2.3.2", "@types/uuid": "^8.3.4", "deep-equal": "^2.0.5", - "ts-graphviz": "^0.16.0", + "ts-graphviz": "^1.5.4", "uuid": "^9.0.0" }, "publishConfig": { diff --git a/query-graphs-js/src/graphviz.ts b/query-graphs-js/src/graphviz.ts index f575a79d5..38437c46e 100644 --- a/query-graphs-js/src/graphviz.ts +++ b/query-graphs-js/src/graphviz.ts @@ -1,10 +1,10 @@ /* Functions used to output query graphs as [graphviz dot](https://graphviz.org/doc/info/lang.html) outputs. */ import { simpleTraversal, Edge, QueryGraph, QueryGraphState, Vertex } from "./querygraph"; -import { attribute, Digraph, digraph, ICluster, IEdge, INode, toDot as graphvizToDot } from 'ts-graphviz'; +import { attribute, digraph, RootGraphModel, GraphBaseModel, EdgeModel, NodeModel, toDot as graphvizToDot } from 'ts-graphviz'; import { RootPath, traversePath } from "./graphPath"; -function setDefaultGraphAttributes(_: Digraph) { +function setDefaultGraphAttributes(_: RootGraphModel) { //vizGraph.attributes.edge.set(attribute.labelfloat, true); } @@ -33,7 +33,7 @@ export function groupToDot( return graphvizToDot(vizGraph); } -function addToVizGraphAndHighlight(graph: QueryGraph, vizGraph: ICluster, config?: DotGraphConfig) { +function addToVizGraphAndHighlight(graph: QueryGraph, vizGraph: GraphBaseModel, config?: DotGraphConfig) { const state = addToVizGraph(graph, vizGraph, config?.noTerminal); highlightPaths(state, config?.highlightedPaths); } @@ -64,7 +64,7 @@ type HighlitedPath = { color: string } -function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolean = false): QueryGraphState { +function addToVizGraph(graph: QueryGraph, vizGraph: GraphBaseModel, noTerminal: boolean = false): QueryGraphState { const vizSubGraphs = new Map(); for (const source of graph.sources.keys()) { if (source != graph.name) { @@ -76,12 +76,12 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea })); } } - const getNode = function (vertex: Vertex): INode { + const getNode = function (vertex: Vertex): NodeModel { const existingNode = state.getVertexState(vertex); if (existingNode) { return existingNode; } - let newNode: INode; + let newNode: NodeModel; if (vertex.source == graph.name) { newNode = vizGraph.createNode(vertex.type.name); } else { @@ -94,13 +94,13 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea state.setVertexState(vertex, newNode); return newNode; } - const pickGraphForEdge = function (head: Vertex, tail: Vertex): ICluster { + const pickGraphForEdge = function (head: Vertex, tail: Vertex): GraphBaseModel { if (head.source == tail.source && head.source != graph.name) { return vizSubGraphs.get(head.source); } return vizGraph; } - const state = new QueryGraphState(graph); + const state = new QueryGraphState(graph); const onEdge = function (edge: Edge): boolean { const head = edge.head; const tail = edge.tail; @@ -119,11 +119,11 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea return state; } -function highlightPaths(state: QueryGraphState, toHighlights?: HighlitedPath[]) { +function highlightPaths(state: QueryGraphState, toHighlights?: HighlitedPath[]) { toHighlights?.forEach(h => highlightPath(state, h)); } -function highlightPath(state: QueryGraphState, toHighlight: HighlitedPath) { +function highlightPath(state: QueryGraphState, toHighlight: HighlitedPath) { traversePath(toHighlight.path, e => { for (const vAttrs of [state.getVertexState(e.head)?.attributes, state.getVertexState(e.tail)?.attributes ]) { vAttrs?.set(attribute.color, toHighlight.color);