Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"rxjs": "~7.8.0",
"sigma": "3.0.1",
"tslib": "^2.3.0",
"typedb-driver-http": "0.0.1",
"@typedb/driver-http": "3.7.0",
"typedb-web-common": "workspace:*",
"uuid": "11.1.0",
"zone.js": "~0.15.1",
Expand Down
17 changes: 8 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/concept/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { ApiResponse, QueryResponse } from "typedb-driver-http";
import { ApiResponse, QueryResponse } from "@typedb/driver-http";
import { TransactionOperation } from "./transaction";

interface DriverActionBase {
Expand Down
2 changes: 1 addition & 1 deletion src/concept/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {
Database, DriverParams, DriverParamsBasic, DriverParamsTranslated, isBasicParams, TranslatedAddress
} from "typedb-driver-http";
} from "@typedb/driver-http";

export class ConnectionConfig {

Expand Down
2 changes: 1 addition & 1 deletion src/concept/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { TransactionType } from "typedb-driver-http";
import { TransactionType } from "@typedb/driver-http";
import { QueryRunAction } from "./action";

export class Transaction {
Expand Down
2 changes: 1 addition & 1 deletion src/framework/graph-visualiser/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EdgeKind, RoleType } from "typedb-driver-http";
import { EdgeKind, RoleType } from "@typedb/driver-http";
import {DataVertex, DataVertexKind, VertexUnavailable} from "./graph";
import {Color} from "chroma-js";

Expand Down
37 changes: 20 additions & 17 deletions src/framework/graph-visualiser/converter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getVariableName, QueryConstraintAny, QueryStructure, QueryVertex } from "typedb-driver-http";
import { getVariableName, ConstraintVertexAny } from "@typedb/driver-http";
import {
EdgeAttributes,
EdgeMetadata,
Expand All @@ -21,13 +21,18 @@ import {
} from "./graph";
import {ILogicalGraphConverter} from "./visualisation";
import {StudioConverterStructureParameters, StudioConverterStyleParameters} from "./config";
import {
AnalyzedPipelineBackCompat,
backCompat_expressionAssigned,
ConstraintBackCompat
} from "./index";

type QueryVertexOrSpecial = QueryVertex | VertexFunction | VertexExpression;
type ConstraintVertexOrSpecial = ConstraintVertexAny | VertexFunction | VertexExpression;

export class StudioConverter implements ILogicalGraphConverter {

constructor(
public readonly graph: VisualGraph, public readonly queryStructure: QueryStructure,
public readonly graph: VisualGraph, public readonly queryStructure: AnalyzedPipelineBackCompat,
public readonly isFollowupQuery: boolean, public readonly structureParameters: StudioConverterStructureParameters,
public readonly styleParameters: StudioConverterStyleParameters
) {
Expand Down Expand Up @@ -81,11 +86,11 @@ export class StudioConverter implements ILogicalGraphConverter {
return `${from_id}:${to_id}:${edge_type_id}`;
}

private shouldCreateNode(queryVertex: QueryVertexOrSpecial) {
private shouldCreateNode(queryVertex: ConstraintVertexOrSpecial) {
return shouldCreateNode(this.queryStructure, queryVertex);
}

private shouldCreateEdge(edge: DataConstraintAny, from: QueryVertexOrSpecial, to: QueryVertexOrSpecial) {
private shouldCreateEdge(edge: DataConstraintAny, from: ConstraintVertexOrSpecial, to: ConstraintVertexOrSpecial) {
return shouldCreateEdge(this.queryStructure, edge.queryConstraint, from, to);
}

Expand All @@ -105,7 +110,7 @@ export class StudioConverter implements ILogicalGraphConverter {
}
}

private maybeCreateEdge(answerIndex: number, edge: DataConstraintAny, label: string, from: DataVertex, to: DataVertex, queryFrom: QueryVertexOrSpecial, queryTo: QueryVertexOrSpecial) {
private maybeCreateEdge(answerIndex: number, edge: DataConstraintAny, label: string, from: DataVertex, to: DataVertex, queryFrom: ConstraintVertexOrSpecial, queryTo: ConstraintVertexOrSpecial) {
if (this.shouldCreateEdge(edge, queryFrom, queryTo)) {
let fromKey = this.put_vertex(answerIndex, from, queryFrom);
let toKey = this.put_vertex(answerIndex, to, queryTo);
Expand All @@ -124,7 +129,7 @@ export class StudioConverter implements ILogicalGraphConverter {

// ILogicalGraphConverter
// Vertices
put_vertex(answerIndex: number, vertex: DataVertex, queryVertex: QueryVertexOrSpecial): string {
put_vertex(answerIndex: number, vertex: DataVertex, queryVertex: ConstraintVertexOrSpecial): string {
const key = vertexMapKey(vertex);
if (this.shouldCreateNode(queryVertex)) {
this.createVertex(key, this.vertexAttributes(vertex))
Expand Down Expand Up @@ -207,13 +212,11 @@ export class StudioConverter implements ILogicalGraphConverter {
repr: constraint.text,
vertex_map_key: expressionVertexKey
}
expression.assigned
.forEach((assigned, i) => {
let queryVertex = constraint.queryConstraint.assigned[i];
let varNameOrId = getVariableName(this.queryStructure, queryVertex) ?? `$_${queryVertex.id}`;
let label = `assign[${varNameOrId}]`;
this.maybeCreateEdge(answerIndex, constraint, label, expressionVertex, assigned, expressionVertex, queryVertex);
});

let queryVertex = backCompat_expressionAssigned(constraint.queryConstraint);
let varNameOrId = getVariableName(this.queryStructure, queryVertex) ?? `$_${queryVertex.id}`;
let label = `assign[${varNameOrId}]`;
this.maybeCreateEdge(answerIndex, constraint, label, expressionVertex, expression.assigned, expressionVertex, queryVertex);
expression.arguments
.forEach((arg, i) => {
let queryVertex = constraint.queryConstraint.arguments[i];
Expand Down Expand Up @@ -253,15 +256,15 @@ export class StudioConverter implements ILogicalGraphConverter {
}
}

export function shouldCreateNode(structure: QueryStructure, vertex: QueryVertexOrSpecial) {
export function shouldCreateNode(structure: AnalyzedPipelineBackCompat, vertex: ConstraintVertexOrSpecial) {
return !(
(vertex.tag === "label" ||
(vertex.tag == "variable" && !structure.outputs.includes(vertex.id))
)
);
}

export function shouldCreateEdge(structure: QueryStructure, _edge: QueryConstraintAny, from: QueryVertexOrSpecial, to: QueryVertexOrSpecial) {
export function shouldCreateEdge(structure: AnalyzedPipelineBackCompat, _edge: ConstraintBackCompat, from: ConstraintVertexOrSpecial, to: ConstraintVertexOrSpecial) {
return shouldCreateNode(structure, from) && shouldCreateNode(structure, to);
}

Expand Down Expand Up @@ -297,6 +300,6 @@ function functionVertexKeyFromArgsAndAssigned(constraint: DataConstraintFunction

function expressionVertexKeyFromArgsAndAssigned(constraint: DataConstraintExpression): string {
let args = constraint.arguments.map(v => vertexMapKey(v)).join(",");
let assigned = constraint.assigned.map(v => vertexMapKey(v)).join(",");
let assigned = constraint.assigned;
return `${constraint.text}(${args}) -> ${assigned}`;
}
2 changes: 1 addition & 1 deletion src/framework/graph-visualiser/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RoleType } from "typedb-driver-http";
import { RoleType } from "@typedb/driver-http";
import chroma from "chroma-js";
import { vertexMapKey } from "./converter";
import {DataVertex, VertexUnavailable} from "./graph";
Expand Down
Loading