From 5804f644ea06a2f542d3b14ee3adf0c248e3a339 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Fri, 14 Nov 2025 14:46:55 +0000 Subject: [PATCH] latest --- .gitignore | 2 + src/types/graph_node_types.ts | 7 +- src/utils/tldraw/cc-base/cc-graph-props.ts | 14 +- src/utils/tldraw/cc-base/cc-graph-types.ts | 11 +- src/utils/tldraw/graph/baseNodeShapeUtil.tsx | 8 +- src/utils/tldraw/graph/graph-shape-props.ts | 7 +- src/utils/tldraw/graph/graphShapeUtil.tsx | 145 +++++++++---------- src/utils/tldraw/graph/graphStateUtil.tsx | 2 +- src/utils/tldraw/graph/nodeComponents.tsx | 2 +- 9 files changed, 97 insertions(+), 101 deletions(-) diff --git a/.gitignore b/.gitignore index 3c3629e..a2e04e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ node_modules + +.env \ No newline at end of file diff --git a/src/types/graph_node_types.ts b/src/types/graph_node_types.ts index ded3f28..9e767b3 100644 --- a/src/types/graph_node_types.ts +++ b/src/types/graph_node_types.ts @@ -3,7 +3,7 @@ export interface BaseNodeInterface { h: number; color: string; __primarylabel__: string; - unique_id: string; + uuid_string: string; path: string; created: string; merged: string; @@ -91,9 +91,8 @@ export interface CalendarTimeChunkNodeInterface extends BaseNodeInterface { // School export interface SchoolNodeInterface extends BaseNodeInterface { - school_name: string; - school_website: string; - school_uuid: string; + name: string; + website: string; } export interface DepartmentNodeInterface extends BaseNodeInterface diff --git a/src/utils/tldraw/cc-base/cc-graph-props.ts b/src/utils/tldraw/cc-base/cc-graph-props.ts index a1ad0a3..af1bab5 100644 --- a/src/utils/tldraw/cc-base/cc-graph-props.ts +++ b/src/utils/tldraw/cc-base/cc-graph-props.ts @@ -14,7 +14,7 @@ const stateProps = T.object({ const graphBaseProps = { ...baseShapeProps, __primarylabel__: T.string, - unique_id: T.string, + uuid_string: T.string, path: T.string, created: T.string, merged: T.string, @@ -84,9 +84,8 @@ export const ccGraphShapeProps = { }, 'cc-school-node': { ...graphBaseProps, - school_uuid: T.string, - school_name: T.string, - school_website: T.string, + name: T.string, + website: T.string, }, 'cc-department-node': { ...graphBaseProps, @@ -283,7 +282,7 @@ export const getDefaultBaseProps = () => ({ backgroundColor: '#f0f0f0' as string, title: 'Untitled' as string, isLocked: false as boolean, - unique_id: '' as string, + uuid_string: '' as string, path: '' as string, created: '' as string, merged: '' as string, @@ -382,9 +381,8 @@ export const getDefaultCCSchoolNodeProps = () => ({ ...getDefaultBaseProps(), title: 'School', __primarylabel__: 'School', - school_uuid: '', - school_name: '', - school_website: '', + name: '', + website: '', }) export const getDefaultCCDepartmentNodeProps = () => ({ diff --git a/src/utils/tldraw/cc-base/cc-graph-types.ts b/src/utils/tldraw/cc-base/cc-graph-types.ts index 64a488d..c6d7408 100644 --- a/src/utils/tldraw/cc-base/cc-graph-types.ts +++ b/src/utils/tldraw/cc-base/cc-graph-types.ts @@ -15,7 +15,7 @@ export interface ShapeState { export type CCGraphShapeProps = CCBaseProps & { __primarylabel__: string - unique_id: string + uuid_string: string path: string created: string merged: string @@ -26,7 +26,7 @@ export type CCGraphShapeProps = CCBaseProps & { // Define the base shape type for graph shapes export type CCGraphShape = CCBaseShape & TLBaseShape { // Helper function to get allowed props from node type export const getAllowedProps = (): string[] => { - return ['__primarylabel__', 'unique_id']; + return ['__primarylabel__', 'uuid_string']; } // Helper function to get node configuration diff --git a/src/utils/tldraw/graph/baseNodeShapeUtil.tsx b/src/utils/tldraw/graph/baseNodeShapeUtil.tsx index 9bb8e87..a26815e 100644 --- a/src/utils/tldraw/graph/baseNodeShapeUtil.tsx +++ b/src/utils/tldraw/graph/baseNodeShapeUtil.tsx @@ -121,9 +121,9 @@ const createNodeComponent = (shape: AllNodeShapes, theme: TLDefaultColorTheme, e } isFetchingConnectedNodes = true; - console.log("Getting connected nodes for:", shape.props.unique_id); + console.log("Getting connected nodes for:", shape.props.uuid_string); try { - const response = await axios.get(`/api/database/tools/get-connected-nodes-and-edges?unique_id=${shape.props.unique_id}`); + const response = await axios.get(`/api/database/tools/get-connected-nodes-and-edges?uuid_string=${shape.props.uuid_string}`); console.log("Connected nodes response:", response.data); if (response.data.status === "success") { const mainNode = response.data.main_node; @@ -133,7 +133,7 @@ const createNodeComponent = (shape: AllNodeShapes, theme: TLDefaultColorTheme, e // Add nodes to the graph [mainNode, ...connectedNodes].forEach((node: any) => { console.log("Node:", node); - const newShapeId = createShapeId(node.node_data.unique_id); + const newShapeId = createShapeId(node.node_data.uuid_string); const doesShapeExist = editor.getShape(newShapeId); if (!doesShapeExist) { console.log("Creating new shape with ID:", newShapeId); @@ -177,7 +177,7 @@ const createNodeComponent = (shape: AllNodeShapes, theme: TLDefaultColorTheme, e // Add edges to the graph relationships.forEach((relationship: any) => { - graphState.addEdge(relationship.start_node.unique_id, relationship.end_node.unique_id); + graphState.addEdge(relationship.start_node.uuid_string, relationship.end_node.uuid_string); }); // Create edge shapes diff --git a/src/utils/tldraw/graph/graph-shape-props.ts b/src/utils/tldraw/graph/graph-shape-props.ts index d8ed81a..994c7ed 100644 --- a/src/utils/tldraw/graph/graph-shape-props.ts +++ b/src/utils/tldraw/graph/graph-shape-props.ts @@ -43,7 +43,7 @@ const baseNodeShapeProps = { h: T.number, color: DefaultColorStyle, __primarylabel__: T.string, - unique_id: T.string, + uuid_string: T.string, path: T.string, created: T.string, merged: T.string, @@ -126,9 +126,8 @@ export const calendarTimeChunkNodeShapeProps: RecordProps = { ...baseNodeShapeProps, - school_name: T.string, - school_website: T.string, - school_uuid: T.string, + name: T.string, + website: T.string, } export const departmentNodeShapeProps: RecordProps = { diff --git a/src/utils/tldraw/graph/graphShapeUtil.tsx b/src/utils/tldraw/graph/graphShapeUtil.tsx index 0d7b14e..a249d58 100644 --- a/src/utils/tldraw/graph/graphShapeUtil.tsx +++ b/src/utils/tldraw/graph/graphShapeUtil.tsx @@ -126,13 +126,13 @@ export class UserNodeShapeUtil extends BaseNodeShapeUtil { h: 200, color: 'blue', __primarylabel__: 'User', - unique_id: '', + uuid_string: '', user_name: '', user_email: '', user_type: '', user_id: '', worker_node_data: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -150,12 +150,12 @@ export class DeveloperNodeShapeUtil extends BaseNodeShapeUtil { h: 200, color: 'white', __primarylabel__: 'Teacher', - unique_id: '', + uuid_string: '', teacher_code: '', teacher_name_formal: '', teacher_email: '', worker_db_name: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -196,12 +196,12 @@ export class StudentNodeShapeUtil extends BaseNodeShapeUtil { h: 200, color: 'white', __primarylabel__: 'Student', - unique_id: '', + uuid_string: '', student_code: '', student_name_formal: '', student_email: '', worker_db_name: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -220,11 +220,11 @@ export class CalendarNodeShapeUtil extends BaseNodeShapeUtil h: 200, color: 'white', __primarylabel__: 'Calendar', - unique_id: '', + uuid_string: '', name: '', start_date: '', end_date: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -242,9 +242,9 @@ export class CalendarYearNodeShapeUtil extends BaseNodeShapeUtil { h: 200, color: 'white', __primarylabel__: 'School', - unique_id: '', - school_uuid: '', - school_name: '', - school_website: '', - path: '', + uuid_string: '', + name: '', + website: '', + node_storage_path: '', created: '', merged: '', } @@ -395,9 +394,9 @@ export class DepartmentNodeShapeUtil extends BaseNodeShapeUtil { h: 200, color: 'white', __primarylabel__: 'Room', - unique_id: '', + uuid_string: '', room_name: '', room_code: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -438,8 +437,8 @@ export class PastoralStructureNodeShapeUtil extends BaseNodeShapeUtil h: 150, color: 'white', __primarylabel__: 'Key Stage', - unique_id: '', + uuid_string: '', key_stage_name: '', key_stage: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -518,13 +517,13 @@ export class KeyStageSyllabusNodeShapeUtil extends BaseNodeShapeUtil { h: 200, color: 'white', __primarylabel__: 'Subject', - unique_id: '', + uuid_string: '', subject_code: '', subject_name: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -587,13 +586,13 @@ export class TopicNodeShapeUtil extends BaseNodeShapeUtil { h: 400, color: 'white', __primarylabel__: 'Topic', - unique_id: '', + uuid_string: '', topic_id: '', topic_title: '', total_number_of_lessons_for_topic: '', topic_type: '', topic_assessment_type: '', - path: '', + node_storage_path: '', created: '', merged: '', } @@ -611,7 +610,7 @@ export class TopicLessonNodeShapeUtil extends BaseNodeShapeUtil { console.log("Adding shape to graphState:", shape); - const id = shape.props.unique_id; + const id = shape.props.uuid_string; console.log("Adding node to graphState:", id); graphState.g.setNode(id, { label: id, diff --git a/src/utils/tldraw/graph/nodeComponents.tsx b/src/utils/tldraw/graph/nodeComponents.tsx index cc63c1b..53bc425 100644 --- a/src/utils/tldraw/graph/nodeComponents.tsx +++ b/src/utils/tldraw/graph/nodeComponents.tsx @@ -8,7 +8,7 @@ interface NodeComponentProps { interface BaseNodeProps { __primarylabel__: string; - unique_id: string; + uuid_string: string; } interface TeacherNodeProps extends BaseNodeProps {