Canvas: Use GraphSchema to validate state
Change-Id: I342c8959c97f3486c4a7cb2aff92fb930a2b3146
diff --git a/apps/canvas/config/src/config.ts b/apps/canvas/config/src/config.ts
index dcc4318..d91b535 100644
--- a/apps/canvas/config/src/config.ts
+++ b/apps/canvas/config/src/config.ts
@@ -2,6 +2,7 @@
AppNode,
BoundEnvVar,
Env,
+ Edge,
GatewayHttpsNode,
GatewayTCPNode,
GithubNode,
@@ -12,8 +13,8 @@
PostgreSQLNode,
ServiceNode,
VolumeNode,
+ Graph,
} from "./graph.js";
-import { Edge } from "@xyflow/react";
import { v4 as uuidv4 } from "uuid";
import { Ingress, Service, Volume, PostgreSQL, MongoDB, Config, PortDomain, isAgent } from "./types.js";
import { GithubRepository } from "./github.js";
@@ -186,12 +187,6 @@
}
}
-export type Graph = {
- nodes: AppNode[];
- edges: Edge[];
- viewport?: { x: number; y: number; zoom: number };
-};
-
export function configToGraph(config: Config, networks: Network[], repos: GithubRepository[], current?: Graph): Graph {
if (current == null) {
current = { nodes: [], edges: [] };
@@ -264,7 +259,6 @@
data: {
label: s.name,
type: s.type,
- env: [],
repository:
s.source != null
? {
@@ -454,7 +448,6 @@
type: "postgresql",
data: {
label: p.name,
- volumeId: "", // TODO(gio): volume
envVars: [],
ports: [
{
@@ -518,7 +511,6 @@
type: "mongodb",
data: {
label: m.name,
- volumeId: "", // TODO(gio): volume
envVars: [],
ports: [
{