From 1d4f992c8702c68c0ae108fc842ba0c64a36b7ed Mon Sep 17 00:00:00 2001
From: erdfern <rexsomnia@pm.me>
Date: Thu, 20 Mar 2025 21:21:41 +0100
Subject: [PATCH] --wip--

---
 db/schema/schema.surql                        |  53 +++--
 .../annotation/annotationSchemaGen.ts         |  73 +++++++
 .../assignment/assignmentSchemaGen.ts         |  40 ++--
 .../evaluation/evaluationSchemaGen.ts         |  37 ++--
 .../exerciseGroup/exerciseGroupSchemaGen.ts   |  11 +-
 .../hasAccount/hasAccountSchemaGen.ts         |  24 +--
 src/lib/surreal/_generated/index.ts           |   3 +-
 .../_generated/memberOf/memberOfSchemaGen.ts  |  12 +-
 .../_generated/module/moduleSchemaGen.ts      |  31 ++-
 .../_generated/review/reviewSchemaGen.ts      |  28 ++-
 .../_generated/reviewer/reviewerSchemaGen.ts  |  11 +-
 .../_generated/student/studentSchemaGen.ts    |  19 +-
 .../submission/submissionSchemaGen.ts         |  60 +++---
 .../_generated/tutor/tutorSchemaGen.ts        |  11 +-
 .../surreal/_generated/user/userSchemaGen.ts  |  31 +--
 .../schema/annotation/annotationSchema.ts     |  20 ++
 .../schema/annotation/annotationTypes.ts      |  13 ++
 src/lib/surreal/schema/annotation/index.ts    |   2 +
 .../schema/assignment/assignmentSchema.ts     |  30 ++-
 .../schema/assignment/assignmentTypes.ts      |  11 +-
 src/lib/surreal/schema/assignment/index.ts    |   2 +-
 .../schema/evaluation/evaluationSchema.ts     |  30 ++-
 .../schema/evaluation/evaluationTypes.ts      |  11 +-
 src/lib/surreal/schema/evaluation/index.ts    |   2 +-
 .../exerciseGroup/exerciseGroupSchema.ts      |  33 ++--
 .../exerciseGroup/exerciseGroupTypes.ts       |  11 +-
 src/lib/surreal/schema/exerciseGroup/index.ts |   2 +-
 .../schema/hasAccount/hasAccountSchema.ts     |  30 ++-
 .../schema/hasAccount/hasAccountTypes.ts      |  11 +-
 src/lib/surreal/schema/hasAccount/index.ts    |   2 +-
 src/lib/surreal/schema/index.ts               |   3 +-
 src/lib/surreal/schema/memberOf/index.ts      |   2 +-
 .../surreal/schema/memberOf/memberOfSchema.ts |  30 ++-
 .../surreal/schema/memberOf/memberOfTypes.ts  |  11 +-
 src/lib/surreal/schema/module/index.ts        |   2 +-
 src/lib/surreal/schema/module/moduleSchema.ts |  30 ++-
 src/lib/surreal/schema/module/moduleTypes.ts  |  11 +-
 src/lib/surreal/schema/review/index.ts        |   2 +-
 src/lib/surreal/schema/review/reviewSchema.ts |  30 ++-
 src/lib/surreal/schema/review/reviewTypes.ts  |  11 +-
 src/lib/surreal/schema/reviewer/index.ts      |   2 +-
 .../surreal/schema/reviewer/reviewerSchema.ts |  30 ++-
 .../surreal/schema/reviewer/reviewerTypes.ts  |  11 +-
 src/lib/surreal/schema/student/index.ts       |   2 +-
 .../surreal/schema/student/studentSchema.ts   |  30 ++-
 .../surreal/schema/student/studentTypes.ts    |  11 +-
 src/lib/surreal/schema/submission/index.ts    |   2 +-
 .../schema/submission/submissionSchema.ts     |  32 ++-
 .../schema/submission/submissionTypes.ts      |  11 +-
 src/lib/surreal/schema/tutor/index.ts         |   2 +-
 src/lib/surreal/schema/tutor/tutorSchema.ts   |  30 ++-
 src/lib/surreal/schema/tutor/tutorTypes.ts    |  11 +-
 src/lib/surreal/schema/user/index.ts          |   2 +-
 src/lib/surreal/schema/user/userSchema.ts     |  30 ++-
 src/lib/surreal/schema/user/userTypes.ts      |  11 +-
 src/lib/zod.ts                                |  97 +---------
 src/routes/(app)/debug/editor/+page.server.ts |  30 ++-
 src/routes/(app)/debug/editor/+page.svelte    |  11 +-
 .../debug/editor/Editor/CodeBlock.svelte      |  37 +++-
 .../(app)/debug/editor/Editor/Editor.svelte   | 182 ++++++++++++++----
 .../(app)/debug/editor/Editor/schema.ts       |  27 +--
 src/routes/(app)/debug/editor/Editor/todo.md  |   8 +-
 src/routes/(app)/debug/editor/Editor/types.ts |  81 ++++----
 src/routes/(app)/debug/editor/db.ts           |  23 ++-
 surql-gen.json                                |   2 +-
 65 files changed, 813 insertions(+), 688 deletions(-)
 create mode 100644 src/lib/surreal/_generated/annotation/annotationSchemaGen.ts
 create mode 100644 src/lib/surreal/schema/annotation/annotationSchema.ts
 create mode 100644 src/lib/surreal/schema/annotation/annotationTypes.ts
 create mode 100644 src/lib/surreal/schema/annotation/index.ts

diff --git a/db/schema/schema.surql b/db/schema/schema.surql
index 3e4e55d7..667c20a4 100644
--- a/db/schema/schema.surql
+++ b/db/schema/schema.surql
@@ -57,7 +57,6 @@ DEFINE FIELD final ON evaluation TYPE bool DEFAULT false PERMISSIONS FULL;
 -- NOTE: making this an edge between evaluation->submission seems overkill
 -- NOTE: but maybe make this a record reference? (https://surrealdb.com/docs/surrealql/datamodel/references)
 -- DEFINE FIELD annotations ON evaluation TYPE array<record<annotation>> DEFAULT [] PERMISSIONS FULL; 
--- DEFINE FIELD annotations ON evaluation TYPE array<record<annotation>> DEFAULT [] PERMISSIONS FULL;
 
 DEFINE FIELD maxScore ON evaluation READONLY VALUE out.out.full_score PERMISSIONS FULL;
 DEFINE FIELD postDeltaScore ON evaluation READONLY VALUE <future> {
@@ -102,12 +101,36 @@ DEFINE INDEX one_per_submission ON evaluation FIELDS out UNIQUE;
 -- ------------------------------
 
 DEFINE TABLE annotation TYPE RELATION IN tutor | reviewer OUT evaluation SCHEMALESS PERMISSIONS NONE;
+
 DEFINE FIELD type ON annotation TYPE "document" | "line" | "range" PERMISSIONS FULL;
 DEFINE FIELD content ON annotation TYPE string PERMISSIONS FULL;
 
 -- DEFINE FIELD meta.author ON annotation TYPE record<tutor> PERMISSIONS FULL;
 DEFINE FIELD meta.scoreDelta ON annotation TYPE option<float>  PERMISSIONS FULL;
 
+-- TODO: figure out how to split this into union specific fields
+
+-- 'line'
+DEFINE FIELD line ON annotation TYPE option<number> PERMISSIONS FULL;
+
+-- 'range'
+DEFINE FIELD range.start.line ON annotation TYPE option<number> PERMISSIONS FULL;
+DEFINE FIELD range.start.column ON annotation TYPE option<number> PERMISSIONS FULL;
+DEFINE FIELD range.start.offset ON annotation TYPE option<number> PERMISSIONS FULL;
+
+DEFINE FIELD range.end.line ON annotation TYPE option<number> PERMISSIONS FULL;
+DEFINE FIELD range.end.column ON annotation TYPE option<number> PERMISSIONS FULL;
+DEFINE FIELD range.end.offset ON annotation TYPE option<number> PERMISSIONS FULL;
+
+-- 'document' | 'line' | 'range'
+DEFINE FIELD visual.color ON annotation TYPE option<string> PERMISSIONS FULL;
+
+-- 'line' | 'range'
+DEFINE FIELD visual.zIndex ON annotation TYPE option<number> PERMISSIONS FULL;
+
+-- 'range'
+DEFINE FIELD visual.underline ON annotation TYPE option<'solid' | 'dashed' | 'dotted'> PERMISSIONS FULL;
+
 DEFINE FIELD time.created_at ON annotation TYPE datetime DEFAULT time::now() PERMISSIONS FULL;
 DEFINE FIELD time.updated_at ON annotation TYPE datetime VALUE time::now() PERMISSIONS FULL;
 
@@ -184,23 +207,21 @@ DEFINE FIELD tests[*].name ON submission TYPE string READONLY PERMISSIONS FULL;
 -- DEFINE FIELD updated_at ON submission TYPE datetime VALUE time::now() READONLY;
 
 -- NOTE: this could also be part of the value at stage, e.g. {"ongoing_evaluation", preliminary_score: ...}
-DEFINE FIELD score on submission VALUE <future> {
-    LET $eval = @<-evaluation;
-    IF $eval == NONE OR $eval.is_empty() { RETURN NONE};
-    RETURN $eval.first().score;
-};
-
-DEFINE FIELD stage ON submission VALUE <future> {
-    LET $eval = @<-evaluation;
-
-    IF $eval == NONE OR $eval.is_empty() { RETURN "pending_evaluation" };
+DEFINE FIELD score on submission VALUE <future> {<-evaluation[$].score};
 
-    LET $review = $eval.first()<-review;
+DEFINE FIELD stage ON submission READONLY VALUE <future> {
+	LET $eval = <-evaluation[$];
 
-    IF $review == NONE OR $review.is_empty() { RETURN "ongoing_evaluation" };
-
-    RETURN IF $review.first().approved { "approved" } ELSE { "pending_approval" };
-} READONLY;
+	RETURN IF !$eval
+		{ 'pending_evaluation' }
+	ELSE IF !$eval<-review[$]
+		{ 'ongoing_evaluation' }
+	ELSE IF $eval<-review[$].approved
+		{ 'reviewed' }
+	ELSE
+		{ 'prending_approval' }
+	;
+} PERMISSIONS FULL;
 
 
 -- ------------------------------
diff --git a/src/lib/surreal/_generated/annotation/annotationSchemaGen.ts b/src/lib/surreal/_generated/annotation/annotationSchemaGen.ts
new file mode 100644
index 00000000..473c242a
--- /dev/null
+++ b/src/lib/surreal/_generated/annotation/annotationSchemaGen.ts
@@ -0,0 +1,73 @@
+// ====================
+// DO NOT EDIT THIS FILE!
+// This file is autogenerated and will be overwritten during generation!
+// ====================
+
+import { z } from "zod";
+import { recordId } from "../recordSchema.js"
+
+// the create schema for table annotation
+export const annotationInputSchemaGen = z.object({
+content: z.string(),
+  in: recordId(),
+  line: z.number().optional(),
+  meta: z.object({
+scoreDelta: z.number().optional()
+  }).optional(),
+  out: recordId('evaluation'),
+  range: z.object({
+end: z.object({
+column: z.number().optional(),
+  line: z.number().optional(),
+  offset: z.number().optional()
+  }).optional(),
+  start: z.object({
+column: z.number().optional(),
+  line: z.number().optional(),
+  offset: z.number().optional()
+  }).optional()
+  }),
+  time: z.object({
+created_at: z.string().datetime().optional(),
+  updated_at: z.string().datetime()
+  }),
+  type: z.unknown(),
+  visual: z.object({
+color: z.string().optional(),
+  underline: z.unknown().optional(),
+  zIndex: z.number().optional()
+  }).optional()
+}).passthrough();
+
+// the select schema for table annotation
+export const annotationOutputSchemaGen = z.object({
+content: z.string(),
+  in: recordId(),
+  line: z.number().optional(),
+  meta: z.object({
+scoreDelta: z.number().optional()
+  }).optional(),
+  out: recordId('evaluation'),
+  range: z.object({
+end: z.object({
+column: z.number().optional(),
+  line: z.number().optional(),
+  offset: z.number().optional()
+  }).optional(),
+  start: z.object({
+column: z.number().optional(),
+  line: z.number().optional(),
+  offset: z.number().optional()
+  }).optional()
+  }),
+  time: z.object({
+created_at: z.string().datetime(),
+  updated_at: z.string().datetime()
+  }),
+  type: z.unknown(),
+  visual: z.object({
+color: z.string().optional(),
+  underline: z.unknown().optional(),
+  zIndex: z.number().optional()
+  }).optional()
+}).passthrough();
diff --git a/src/lib/surreal/_generated/assignment/assignmentSchemaGen.ts b/src/lib/surreal/_generated/assignment/assignmentSchemaGen.ts
index a2ee2dc2..5e31debe 100644
--- a/src/lib/surreal/_generated/assignment/assignmentSchemaGen.ts
+++ b/src/lib/surreal/_generated/assignment/assignmentSchemaGen.ts
@@ -3,29 +3,25 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
-import { recordId } from '../recordSchema.js';
+import { z } from "zod";
+import { recordId } from "../recordSchema.js"
 
 // the create schema for table assignment
-export const assignmentInputSchemaGen = z
-	.object({
-		description: z.string(),
-		full_score: z.number(),
-		module: recordId('module'),
-		name: z.string(),
-		programming_language: z.string(),
-		solution: z.string()
-	})
-	.passthrough();
+export const assignmentInputSchemaGen = z.object({
+description: z.string(),
+  full_score: z.number(),
+  module: recordId('module'),
+  name: z.string(),
+  programming_language: z.string(),
+  solution: z.string()
+}).passthrough();
 
 // the select schema for table assignment
-export const assignmentOutputSchemaGen = z
-	.object({
-		description: z.string(),
-		full_score: z.number(),
-		module: recordId('module'),
-		name: z.string(),
-		programming_language: z.string(),
-		solution: z.string()
-	})
-	.passthrough();
+export const assignmentOutputSchemaGen = z.object({
+description: z.string(),
+  full_score: z.number(),
+  module: recordId('module'),
+  name: z.string(),
+  programming_language: z.string(),
+  solution: z.string()
+}).passthrough();
diff --git a/src/lib/surreal/_generated/evaluation/evaluationSchemaGen.ts b/src/lib/surreal/_generated/evaluation/evaluationSchemaGen.ts
index 1800f637..2f294277 100644
--- a/src/lib/surreal/_generated/evaluation/evaluationSchemaGen.ts
+++ b/src/lib/surreal/_generated/evaluation/evaluationSchemaGen.ts
@@ -3,27 +3,24 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
-import { recordId } from '../recordSchema.js';
+import { z } from "zod";
+import { recordId } from "../recordSchema.js"
 
 // the create schema for table evaluation
-export const evaluationInputSchemaGen = z
-	.object({
-		annotations: z.object({}).array(),
-		final: z.boolean().optional(),
-		in: recordId('tutor'),
-		out: recordId('submission'),
-		score: z.number().optional()
-	})
-	.passthrough();
+export const evaluationInputSchemaGen = z.object({
+final: z.boolean().optional(),
+  in: recordId('tutor'),
+  maxScore: z.unknown(),
+  out: recordId('submission'),
+  score: z.number().optional()
+}).passthrough();
 
 // the select schema for table evaluation
-export const evaluationOutputSchemaGen = z
-	.object({
-		annotations: z.object({}).array(),
-		final: z.boolean(),
-		in: recordId('tutor'),
-		out: recordId('submission'),
-		score: z.number().optional()
-	})
-	.passthrough();
+export const evaluationOutputSchemaGen = z.object({
+final: z.boolean(),
+  in: recordId('tutor'),
+  maxScore: z.unknown(),
+  out: recordId('submission'),
+  postDeltaScore: z.unknown(),
+  score: z.number().optional()
+}).passthrough();
diff --git a/src/lib/surreal/_generated/exerciseGroup/exerciseGroupSchemaGen.ts b/src/lib/surreal/_generated/exerciseGroup/exerciseGroupSchemaGen.ts
index 6aa33c65..9ef07806 100644
--- a/src/lib/surreal/_generated/exerciseGroup/exerciseGroupSchemaGen.ts
+++ b/src/lib/surreal/_generated/exerciseGroup/exerciseGroupSchemaGen.ts
@@ -3,10 +3,15 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
+import { z } from "zod";
+
 
 // the create schema for table exercise_group
-export const exerciseGroupInputSchemaGen = z.object({}).passthrough();
+export const exerciseGroupInputSchemaGen = z.object({
+
+}).passthrough();
 
 // the select schema for table exercise_group
-export const exerciseGroupOutputSchemaGen = z.object({}).passthrough();
+export const exerciseGroupOutputSchemaGen = z.object({
+
+}).passthrough();
diff --git a/src/lib/surreal/_generated/hasAccount/hasAccountSchemaGen.ts b/src/lib/surreal/_generated/hasAccount/hasAccountSchemaGen.ts
index e1b314ca..c33d153a 100644
--- a/src/lib/surreal/_generated/hasAccount/hasAccountSchemaGen.ts
+++ b/src/lib/surreal/_generated/hasAccount/hasAccountSchemaGen.ts
@@ -3,21 +3,17 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
-import { recordId } from '../recordSchema.js';
+import { z } from "zod";
+import { recordId } from "../recordSchema.js"
 
 // the create schema for table has_account
-export const hasAccountInputSchemaGen = z
-	.object({
-		in: recordId(),
-		out: recordId('user')
-	})
-	.passthrough();
+export const hasAccountInputSchemaGen = z.object({
+in: recordId(),
+  out: recordId('user')
+}).passthrough();
 
 // the select schema for table has_account
-export const hasAccountOutputSchemaGen = z
-	.object({
-		in: recordId(),
-		out: recordId('user')
-	})
-	.passthrough();
+export const hasAccountOutputSchemaGen = z.object({
+in: recordId(),
+  out: recordId('user')
+}).passthrough();
diff --git a/src/lib/surreal/_generated/index.ts b/src/lib/surreal/_generated/index.ts
index bb7fc4cb..a2574476 100644
--- a/src/lib/surreal/_generated/index.ts
+++ b/src/lib/surreal/_generated/index.ts
@@ -1,3 +1,4 @@
+export * from './annotation/annotationSchemaGen.js';
 export * from './assignment/assignmentSchemaGen.js';
 export * from './evaluation/evaluationSchemaGen.js';
 export * from './exerciseGroup/exerciseGroupSchemaGen.js';
@@ -9,4 +10,4 @@ export * from './reviewer/reviewerSchemaGen.js';
 export * from './student/studentSchemaGen.js';
 export * from './submission/submissionSchemaGen.js';
 export * from './tutor/tutorSchemaGen.js';
-export * from './user/userSchemaGen.js';
+export * from './user/userSchemaGen.js';
\ No newline at end of file
diff --git a/src/lib/surreal/_generated/memberOf/memberOfSchemaGen.ts b/src/lib/surreal/_generated/memberOf/memberOfSchemaGen.ts
index 9d7b73db..961e7504 100644
--- a/src/lib/surreal/_generated/memberOf/memberOfSchemaGen.ts
+++ b/src/lib/surreal/_generated/memberOf/memberOfSchemaGen.ts
@@ -3,17 +3,17 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
-import { recordId } from '../recordSchema.js';
+import { z } from "zod";
+import { recordId } from "../recordSchema.js"
 
 // the create schema for table member_of
 export const memberOfInputSchemaGen = z.object({
-	in: recordId('student'),
-	out: recordId('exercise_group')
+in: recordId('student'),
+  out: recordId('exercise_group')
 });
 
 // the select schema for table member_of
 export const memberOfOutputSchemaGen = z.object({
-	in: recordId('student'),
-	out: recordId('exercise_group')
+in: recordId('student'),
+  out: recordId('exercise_group')
 });
diff --git a/src/lib/surreal/_generated/module/moduleSchemaGen.ts b/src/lib/surreal/_generated/module/moduleSchemaGen.ts
index c4d29f0a..cd169716 100644
--- a/src/lib/surreal/_generated/module/moduleSchemaGen.ts
+++ b/src/lib/surreal/_generated/module/moduleSchemaGen.ts
@@ -3,24 +3,21 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
+import { z } from "zod";
+
 
 // the create schema for table module
-export const moduleInputSchemaGen = z
-	.object({
-		pass_score: z.number(),
-		reference: z.string(),
-		total_score: z.number(),
-		ungraded: z.boolean().optional()
-	})
-	.passthrough();
+export const moduleInputSchemaGen = z.object({
+pass_score: z.number(),
+  reference: z.string(),
+  total_score: z.number(),
+  ungraded: z.boolean().optional()
+}).passthrough();
 
 // the select schema for table module
-export const moduleOutputSchemaGen = z
-	.object({
-		pass_score: z.number(),
-		reference: z.string(),
-		total_score: z.number(),
-		ungraded: z.boolean()
-	})
-	.passthrough();
+export const moduleOutputSchemaGen = z.object({
+pass_score: z.number(),
+  reference: z.string(),
+  total_score: z.number(),
+  ungraded: z.boolean()
+}).passthrough();
diff --git a/src/lib/surreal/_generated/review/reviewSchemaGen.ts b/src/lib/surreal/_generated/review/reviewSchemaGen.ts
index b274910e..7ae0b31f 100644
--- a/src/lib/surreal/_generated/review/reviewSchemaGen.ts
+++ b/src/lib/surreal/_generated/review/reviewSchemaGen.ts
@@ -3,23 +3,19 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
-import { recordId } from '../recordSchema.js';
+import { z } from "zod";
+import { recordId } from "../recordSchema.js"
 
 // the create schema for table review
-export const reviewInputSchemaGen = z
-	.object({
-		approved: z.boolean(),
-		in: recordId('reviewer'),
-		out: recordId('evaluation')
-	})
-	.passthrough();
+export const reviewInputSchemaGen = z.object({
+approved: z.boolean(),
+  in: recordId('reviewer'),
+  out: recordId('evaluation')
+}).passthrough();
 
 // the select schema for table review
-export const reviewOutputSchemaGen = z
-	.object({
-		approved: z.boolean(),
-		in: recordId('reviewer'),
-		out: recordId('evaluation')
-	})
-	.passthrough();
+export const reviewOutputSchemaGen = z.object({
+approved: z.boolean(),
+  in: recordId('reviewer'),
+  out: recordId('evaluation')
+}).passthrough();
diff --git a/src/lib/surreal/_generated/reviewer/reviewerSchemaGen.ts b/src/lib/surreal/_generated/reviewer/reviewerSchemaGen.ts
index 3946c054..71146978 100644
--- a/src/lib/surreal/_generated/reviewer/reviewerSchemaGen.ts
+++ b/src/lib/surreal/_generated/reviewer/reviewerSchemaGen.ts
@@ -3,10 +3,15 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
+import { z } from "zod";
+
 
 // the create schema for table reviewer
-export const reviewerInputSchemaGen = z.object({}).passthrough();
+export const reviewerInputSchemaGen = z.object({
+
+}).passthrough();
 
 // the select schema for table reviewer
-export const reviewerOutputSchemaGen = z.object({}).passthrough();
+export const reviewerOutputSchemaGen = z.object({
+
+}).passthrough();
diff --git a/src/lib/surreal/_generated/student/studentSchemaGen.ts b/src/lib/surreal/_generated/student/studentSchemaGen.ts
index b6bde751..c3ba1487 100644
--- a/src/lib/surreal/_generated/student/studentSchemaGen.ts
+++ b/src/lib/surreal/_generated/student/studentSchemaGen.ts
@@ -3,18 +3,15 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
+import { z } from "zod";
+
 
 // the create schema for table student
-export const studentInputSchemaGen = z
-	.object({
-		alias: z.string()
-	})
-	.passthrough();
+export const studentInputSchemaGen = z.object({
+alias: z.string()
+}).passthrough();
 
 // the select schema for table student
-export const studentOutputSchemaGen = z
-	.object({
-		alias: z.string()
-	})
-	.passthrough();
+export const studentOutputSchemaGen = z.object({
+alias: z.string()
+}).passthrough();
diff --git a/src/lib/surreal/_generated/submission/submissionSchemaGen.ts b/src/lib/surreal/_generated/submission/submissionSchemaGen.ts
index 71fa87cc..0b9f0068 100644
--- a/src/lib/surreal/_generated/submission/submissionSchemaGen.ts
+++ b/src/lib/surreal/_generated/submission/submissionSchemaGen.ts
@@ -3,41 +3,33 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
-import { recordId } from '../recordSchema.js';
+import { z } from "zod";
+import { recordId } from "../recordSchema.js"
 
 // the create schema for table submission
-export const submissionInputSchemaGen = z
-	.object({
-		code: z.string(),
-		in: recordId(),
-		out: recordId('assignment'),
-		source_code: z.string().optional(),
-		tests: z
-			.object({
-				annotation: z.string().optional(),
-				label: z.string(),
-				name: z.string()
-			})
-			.array()
-	})
-	.passthrough();
+export const submissionInputSchemaGen = z.object({
+code: z.string(),
+  in: recordId(),
+  out: recordId('assignment'),
+  source_code: z.string().optional(),
+  tests: z.object({
+annotation: z.string().optional(),
+  label: z.string(),
+  name: z.string()
+  }).array()
+}).passthrough();
 
 // the select schema for table submission
-export const submissionOutputSchemaGen = z
-	.object({
-		code: z.string(),
-		in: recordId(),
-		out: recordId('assignment'),
-		score: z.unknown(),
-		source_code: z.string().optional(),
-		stage: z.unknown(),
-		tests: z
-			.object({
-				annotation: z.string().optional(),
-				label: z.string(),
-				name: z.string()
-			})
-			.array()
-	})
-	.passthrough();
+export const submissionOutputSchemaGen = z.object({
+code: z.string(),
+  in: recordId(),
+  out: recordId('assignment'),
+  score: z.unknown(),
+  source_code: z.string().optional(),
+  stage: z.unknown(),
+  tests: z.object({
+annotation: z.string().optional(),
+  label: z.string(),
+  name: z.string()
+  }).array()
+}).passthrough();
diff --git a/src/lib/surreal/_generated/tutor/tutorSchemaGen.ts b/src/lib/surreal/_generated/tutor/tutorSchemaGen.ts
index 149036bd..a98229c6 100644
--- a/src/lib/surreal/_generated/tutor/tutorSchemaGen.ts
+++ b/src/lib/surreal/_generated/tutor/tutorSchemaGen.ts
@@ -3,10 +3,15 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
+import { z } from "zod";
+
 
 // the create schema for table tutor
-export const tutorInputSchemaGen = z.object({}).passthrough();
+export const tutorInputSchemaGen = z.object({
+
+}).passthrough();
 
 // the select schema for table tutor
-export const tutorOutputSchemaGen = z.object({}).passthrough();
+export const tutorOutputSchemaGen = z.object({
+
+}).passthrough();
diff --git a/src/lib/surreal/_generated/user/userSchemaGen.ts b/src/lib/surreal/_generated/user/userSchemaGen.ts
index 3c30f56f..0a8464dd 100644
--- a/src/lib/surreal/_generated/user/userSchemaGen.ts
+++ b/src/lib/surreal/_generated/user/userSchemaGen.ts
@@ -3,26 +3,27 @@
 // This file is autogenerated and will be overwritten during generation!
 // ====================
 
-import { z } from 'zod';
+import { z } from "zod";
+
 
 // the create schema for table user
 export const userInputSchemaGen = z.object({
-	activation_expires: z.string().datetime().optional(),
-	activation_token: z.string().optional(),
-	email: z.string().email(),
-	enabled: z.boolean(),
-	name: z.string(),
-	password_hash: z.string().optional(),
-	roles: z.unknown().array()
+activation_expires: z.string().datetime().optional(),
+  activation_token: z.string().optional(),
+  email: z.string().email(),
+  enabled: z.boolean(),
+  name: z.string(),
+  password_hash: z.string().optional(),
+  roles: z.unknown().array()
 });
 
 // the select schema for table user
 export const userOutputSchemaGen = z.object({
-	activation_expires: z.string().datetime(),
-	activation_token: z.string(),
-	email: z.string().email(),
-	enabled: z.boolean(),
-	name: z.string(),
-	password_hash: z.string(),
-	roles: z.unknown().array()
+activation_expires: z.string().datetime(),
+  activation_token: z.string(),
+  email: z.string().email(),
+  enabled: z.boolean(),
+  name: z.string(),
+  password_hash: z.string(),
+  roles: z.unknown().array()
 });
diff --git a/src/lib/surreal/schema/annotation/annotationSchema.ts b/src/lib/surreal/schema/annotation/annotationSchema.ts
new file mode 100644
index 00000000..3e5006b7
--- /dev/null
+++ b/src/lib/surreal/schema/annotation/annotationSchema.ts
@@ -0,0 +1,20 @@
+/* Place your custom changes here */
+
+import { z } from "zod";
+
+import { annotationInputSchemaGen, annotationOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
+
+// payload schema for creating a new annotation entity
+export const annotationCreateSchema = annotationInputSchemaGen.merge(z.object({
+  id: recordId("annotation").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
+
+// payload schema for fetching a annotation entity
+export const annotationSchema = annotationOutputSchemaGen.merge(z.object({
+  id: recordId("annotation"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/annotation/annotationTypes.ts b/src/lib/surreal/schema/annotation/annotationTypes.ts
new file mode 100644
index 00000000..f85c4f31
--- /dev/null
+++ b/src/lib/surreal/schema/annotation/annotationTypes.ts
@@ -0,0 +1,13 @@
+/* Place your custom changes here */
+
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
+
+import { annotationCreateSchema, annotationSchema } from "./annotationSchema.js";
+
+// the create type for table annotation
+export type AnnotationCreate = z.input<typeof annotationCreateSchema>
+
+// the select type for table annotation
+export type Annotation = z.output<typeof annotationSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/annotation/index.ts b/src/lib/surreal/schema/annotation/index.ts
new file mode 100644
index 00000000..bdaeb64e
--- /dev/null
+++ b/src/lib/surreal/schema/annotation/index.ts
@@ -0,0 +1,2 @@
+export * from './annotationSchema.js';
+export * from './annotationTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/assignment/assignmentSchema.ts b/src/lib/surreal/schema/assignment/assignmentSchema.ts
index 3c70dc2a..2bc47745 100644
--- a/src/lib/surreal/schema/assignment/assignmentSchema.ts
+++ b/src/lib/surreal/schema/assignment/assignmentSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { assignmentInputSchemaGen, assignmentOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { assignmentInputSchemaGen, assignmentOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new assignment entity
-export const assignmentCreateSchema = assignmentInputSchemaGen.merge(
-	z.object({
-		id: recordId('assignment').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const assignmentCreateSchema = assignmentInputSchemaGen.merge(z.object({
+  id: recordId("assignment").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a assignment entity
-export const assignmentSchema = assignmentOutputSchemaGen.merge(
-	z.object({
-		id: recordId('assignment')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const assignmentSchema = assignmentOutputSchemaGen.merge(z.object({
+  id: recordId("assignment"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/assignment/assignmentTypes.ts b/src/lib/surreal/schema/assignment/assignmentTypes.ts
index 710e40ed..5ebcdd57 100644
--- a/src/lib/surreal/schema/assignment/assignmentTypes.ts
+++ b/src/lib/surreal/schema/assignment/assignmentTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { assignmentCreateSchema, assignmentSchema } from './assignmentSchema.js';
+import { assignmentCreateSchema, assignmentSchema } from "./assignmentSchema.js";
 
 // the create type for table assignment
-export type AssignmentCreate = z.input<typeof assignmentCreateSchema>;
+export type AssignmentCreate = z.input<typeof assignmentCreateSchema>
 
 // the select type for table assignment
-export type Assignment = z.output<typeof assignmentSchema> & { id: RecordId<string> };
+export type Assignment = z.output<typeof assignmentSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/assignment/index.ts b/src/lib/surreal/schema/assignment/index.ts
index f135dfd0..dbadad90 100644
--- a/src/lib/surreal/schema/assignment/index.ts
+++ b/src/lib/surreal/schema/assignment/index.ts
@@ -1,2 +1,2 @@
 export * from './assignmentSchema.js';
-export * from './assignmentTypes.js';
+export * from './assignmentTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/evaluation/evaluationSchema.ts b/src/lib/surreal/schema/evaluation/evaluationSchema.ts
index 650afb63..adbcb843 100644
--- a/src/lib/surreal/schema/evaluation/evaluationSchema.ts
+++ b/src/lib/surreal/schema/evaluation/evaluationSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { evaluationInputSchemaGen, evaluationOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { evaluationInputSchemaGen, evaluationOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new evaluation entity
-export const evaluationCreateSchema = evaluationInputSchemaGen.merge(
-	z.object({
-		id: recordId('evaluation').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const evaluationCreateSchema = evaluationInputSchemaGen.merge(z.object({
+  id: recordId("evaluation").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a evaluation entity
-export const evaluationSchema = evaluationOutputSchemaGen.merge(
-	z.object({
-		id: recordId('evaluation')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const evaluationSchema = evaluationOutputSchemaGen.merge(z.object({
+  id: recordId("evaluation"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/evaluation/evaluationTypes.ts b/src/lib/surreal/schema/evaluation/evaluationTypes.ts
index 6dbedcbf..16e12153 100644
--- a/src/lib/surreal/schema/evaluation/evaluationTypes.ts
+++ b/src/lib/surreal/schema/evaluation/evaluationTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { evaluationCreateSchema, evaluationSchema } from './evaluationSchema.js';
+import { evaluationCreateSchema, evaluationSchema } from "./evaluationSchema.js";
 
 // the create type for table evaluation
-export type EvaluationCreate = z.input<typeof evaluationCreateSchema>;
+export type EvaluationCreate = z.input<typeof evaluationCreateSchema>
 
 // the select type for table evaluation
-export type Evaluation = z.output<typeof evaluationSchema> & { id: RecordId<string> };
+export type Evaluation = z.output<typeof evaluationSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/evaluation/index.ts b/src/lib/surreal/schema/evaluation/index.ts
index 23b9b489..099144dd 100644
--- a/src/lib/surreal/schema/evaluation/index.ts
+++ b/src/lib/surreal/schema/evaluation/index.ts
@@ -1,2 +1,2 @@
 export * from './evaluationSchema.js';
-export * from './evaluationTypes.js';
+export * from './evaluationTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/exerciseGroup/exerciseGroupSchema.ts b/src/lib/surreal/schema/exerciseGroup/exerciseGroupSchema.ts
index 7ac86b28..0fb12bce 100644
--- a/src/lib/surreal/schema/exerciseGroup/exerciseGroupSchema.ts
+++ b/src/lib/surreal/schema/exerciseGroup/exerciseGroupSchema.ts
@@ -1,27 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import {
-	exerciseGroupInputSchemaGen,
-	exerciseGroupOutputSchemaGen
-} from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { exerciseGroupInputSchemaGen, exerciseGroupOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new exercise_group entity
-export const exerciseGroupCreateSchema = exerciseGroupInputSchemaGen.merge(
-	z.object({
-		id: recordId('exercise_group').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const exerciseGroupCreateSchema = exerciseGroupInputSchemaGen.merge(z.object({
+  id: recordId("exercise_group").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a exercise_group entity
-export const exerciseGroupSchema = exerciseGroupOutputSchemaGen.merge(
-	z.object({
-		id: recordId('exercise_group')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const exerciseGroupSchema = exerciseGroupOutputSchemaGen.merge(z.object({
+  id: recordId("exercise_group"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/exerciseGroup/exerciseGroupTypes.ts b/src/lib/surreal/schema/exerciseGroup/exerciseGroupTypes.ts
index 1f4abae0..588d61dd 100644
--- a/src/lib/surreal/schema/exerciseGroup/exerciseGroupTypes.ts
+++ b/src/lib/surreal/schema/exerciseGroup/exerciseGroupTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { exerciseGroupCreateSchema, exerciseGroupSchema } from './exerciseGroupSchema.js';
+import { exerciseGroupCreateSchema, exerciseGroupSchema } from "./exerciseGroupSchema.js";
 
 // the create type for table exercise_group
-export type ExerciseGroupCreate = z.input<typeof exerciseGroupCreateSchema>;
+export type ExerciseGroupCreate = z.input<typeof exerciseGroupCreateSchema>
 
 // the select type for table exercise_group
-export type ExerciseGroup = z.output<typeof exerciseGroupSchema> & { id: RecordId<string> };
+export type ExerciseGroup = z.output<typeof exerciseGroupSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/exerciseGroup/index.ts b/src/lib/surreal/schema/exerciseGroup/index.ts
index 7b5acb59..4d82a37a 100644
--- a/src/lib/surreal/schema/exerciseGroup/index.ts
+++ b/src/lib/surreal/schema/exerciseGroup/index.ts
@@ -1,2 +1,2 @@
 export * from './exerciseGroupSchema.js';
-export * from './exerciseGroupTypes.js';
+export * from './exerciseGroupTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/hasAccount/hasAccountSchema.ts b/src/lib/surreal/schema/hasAccount/hasAccountSchema.ts
index 0f84a47b..e54b0ee7 100644
--- a/src/lib/surreal/schema/hasAccount/hasAccountSchema.ts
+++ b/src/lib/surreal/schema/hasAccount/hasAccountSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { hasAccountInputSchemaGen, hasAccountOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { hasAccountInputSchemaGen, hasAccountOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new has_account entity
-export const hasAccountCreateSchema = hasAccountInputSchemaGen.merge(
-	z.object({
-		id: recordId('has_account').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const hasAccountCreateSchema = hasAccountInputSchemaGen.merge(z.object({
+  id: recordId("has_account").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a has_account entity
-export const hasAccountSchema = hasAccountOutputSchemaGen.merge(
-	z.object({
-		id: recordId('has_account')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const hasAccountSchema = hasAccountOutputSchemaGen.merge(z.object({
+  id: recordId("has_account"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/hasAccount/hasAccountTypes.ts b/src/lib/surreal/schema/hasAccount/hasAccountTypes.ts
index 783d27d7..7369c991 100644
--- a/src/lib/surreal/schema/hasAccount/hasAccountTypes.ts
+++ b/src/lib/surreal/schema/hasAccount/hasAccountTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { hasAccountCreateSchema, hasAccountSchema } from './hasAccountSchema.js';
+import { hasAccountCreateSchema, hasAccountSchema } from "./hasAccountSchema.js";
 
 // the create type for table has_account
-export type HasAccountCreate = z.input<typeof hasAccountCreateSchema>;
+export type HasAccountCreate = z.input<typeof hasAccountCreateSchema>
 
 // the select type for table has_account
-export type HasAccount = z.output<typeof hasAccountSchema> & { id: RecordId<string> };
+export type HasAccount = z.output<typeof hasAccountSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/hasAccount/index.ts b/src/lib/surreal/schema/hasAccount/index.ts
index 84a5fbc8..1b493655 100644
--- a/src/lib/surreal/schema/hasAccount/index.ts
+++ b/src/lib/surreal/schema/hasAccount/index.ts
@@ -1,2 +1,2 @@
 export * from './hasAccountSchema.js';
-export * from './hasAccountTypes.js';
+export * from './hasAccountTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/index.ts b/src/lib/surreal/schema/index.ts
index bf80fe0e..31c88524 100644
--- a/src/lib/surreal/schema/index.ts
+++ b/src/lib/surreal/schema/index.ts
@@ -1,3 +1,4 @@
+export * from './annotation/index.js';
 export * from './assignment/index.js';
 export * from './evaluation/index.js';
 export * from './exerciseGroup/index.js';
@@ -9,4 +10,4 @@ export * from './reviewer/index.js';
 export * from './student/index.js';
 export * from './submission/index.js';
 export * from './tutor/index.js';
-export * from './user/index.js';
+export * from './user/index.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/memberOf/index.ts b/src/lib/surreal/schema/memberOf/index.ts
index c8eeda27..c4e424f0 100644
--- a/src/lib/surreal/schema/memberOf/index.ts
+++ b/src/lib/surreal/schema/memberOf/index.ts
@@ -1,2 +1,2 @@
 export * from './memberOfSchema.js';
-export * from './memberOfTypes.js';
+export * from './memberOfTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/memberOf/memberOfSchema.ts b/src/lib/surreal/schema/memberOf/memberOfSchema.ts
index 0f5279a5..558d74f0 100644
--- a/src/lib/surreal/schema/memberOf/memberOfSchema.ts
+++ b/src/lib/surreal/schema/memberOf/memberOfSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { memberOfInputSchemaGen, memberOfOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { memberOfInputSchemaGen, memberOfOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new member_of entity
-export const memberOfCreateSchema = memberOfInputSchemaGen.merge(
-	z.object({
-		id: recordId('member_of').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const memberOfCreateSchema = memberOfInputSchemaGen.merge(z.object({
+  id: recordId("member_of").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a member_of entity
-export const memberOfSchema = memberOfOutputSchemaGen.merge(
-	z.object({
-		id: recordId('member_of')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const memberOfSchema = memberOfOutputSchemaGen.merge(z.object({
+  id: recordId("member_of"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/memberOf/memberOfTypes.ts b/src/lib/surreal/schema/memberOf/memberOfTypes.ts
index 061d08c1..ed35201d 100644
--- a/src/lib/surreal/schema/memberOf/memberOfTypes.ts
+++ b/src/lib/surreal/schema/memberOf/memberOfTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { memberOfCreateSchema, memberOfSchema } from './memberOfSchema.js';
+import { memberOfCreateSchema, memberOfSchema } from "./memberOfSchema.js";
 
 // the create type for table member_of
-export type MemberOfCreate = z.input<typeof memberOfCreateSchema>;
+export type MemberOfCreate = z.input<typeof memberOfCreateSchema>
 
 // the select type for table member_of
-export type MemberOf = z.output<typeof memberOfSchema> & { id: RecordId<string> };
+export type MemberOf = z.output<typeof memberOfSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/module/index.ts b/src/lib/surreal/schema/module/index.ts
index 9a3cf8a8..3ab05bf9 100644
--- a/src/lib/surreal/schema/module/index.ts
+++ b/src/lib/surreal/schema/module/index.ts
@@ -1,2 +1,2 @@
 export * from './moduleSchema.js';
-export * from './moduleTypes.js';
+export * from './moduleTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/module/moduleSchema.ts b/src/lib/surreal/schema/module/moduleSchema.ts
index b7ff7a78..3c400c00 100644
--- a/src/lib/surreal/schema/module/moduleSchema.ts
+++ b/src/lib/surreal/schema/module/moduleSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { moduleInputSchemaGen, moduleOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { moduleInputSchemaGen, moduleOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new module entity
-export const moduleCreateSchema = moduleInputSchemaGen.merge(
-	z.object({
-		id: recordId('module').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const moduleCreateSchema = moduleInputSchemaGen.merge(z.object({
+  id: recordId("module").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a module entity
-export const moduleSchema = moduleOutputSchemaGen.merge(
-	z.object({
-		id: recordId('module')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const moduleSchema = moduleOutputSchemaGen.merge(z.object({
+  id: recordId("module"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/module/moduleTypes.ts b/src/lib/surreal/schema/module/moduleTypes.ts
index 1ad90fa4..ee2b7a57 100644
--- a/src/lib/surreal/schema/module/moduleTypes.ts
+++ b/src/lib/surreal/schema/module/moduleTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { moduleCreateSchema, moduleSchema } from './moduleSchema.js';
+import { moduleCreateSchema, moduleSchema } from "./moduleSchema.js";
 
 // the create type for table module
-export type ModuleCreate = z.input<typeof moduleCreateSchema>;
+export type ModuleCreate = z.input<typeof moduleCreateSchema>
 
 // the select type for table module
-export type Module = z.output<typeof moduleSchema> & { id: RecordId<string> };
+export type Module = z.output<typeof moduleSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/review/index.ts b/src/lib/surreal/schema/review/index.ts
index b16a224c..339c9c7d 100644
--- a/src/lib/surreal/schema/review/index.ts
+++ b/src/lib/surreal/schema/review/index.ts
@@ -1,2 +1,2 @@
 export * from './reviewSchema.js';
-export * from './reviewTypes.js';
+export * from './reviewTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/review/reviewSchema.ts b/src/lib/surreal/schema/review/reviewSchema.ts
index b3e9961a..735e4410 100644
--- a/src/lib/surreal/schema/review/reviewSchema.ts
+++ b/src/lib/surreal/schema/review/reviewSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { reviewInputSchemaGen, reviewOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { reviewInputSchemaGen, reviewOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new review entity
-export const reviewCreateSchema = reviewInputSchemaGen.merge(
-	z.object({
-		id: recordId('review').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const reviewCreateSchema = reviewInputSchemaGen.merge(z.object({
+  id: recordId("review").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a review entity
-export const reviewSchema = reviewOutputSchemaGen.merge(
-	z.object({
-		id: recordId('review')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const reviewSchema = reviewOutputSchemaGen.merge(z.object({
+  id: recordId("review"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/review/reviewTypes.ts b/src/lib/surreal/schema/review/reviewTypes.ts
index a0db3d9d..5aededc2 100644
--- a/src/lib/surreal/schema/review/reviewTypes.ts
+++ b/src/lib/surreal/schema/review/reviewTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { reviewCreateSchema, reviewSchema } from './reviewSchema.js';
+import { reviewCreateSchema, reviewSchema } from "./reviewSchema.js";
 
 // the create type for table review
-export type ReviewCreate = z.input<typeof reviewCreateSchema>;
+export type ReviewCreate = z.input<typeof reviewCreateSchema>
 
 // the select type for table review
-export type Review = z.output<typeof reviewSchema> & { id: RecordId<string> };
+export type Review = z.output<typeof reviewSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/reviewer/index.ts b/src/lib/surreal/schema/reviewer/index.ts
index 4adefd11..0aafabd1 100644
--- a/src/lib/surreal/schema/reviewer/index.ts
+++ b/src/lib/surreal/schema/reviewer/index.ts
@@ -1,2 +1,2 @@
 export * from './reviewerSchema.js';
-export * from './reviewerTypes.js';
+export * from './reviewerTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/reviewer/reviewerSchema.ts b/src/lib/surreal/schema/reviewer/reviewerSchema.ts
index 7091438e..2480f876 100644
--- a/src/lib/surreal/schema/reviewer/reviewerSchema.ts
+++ b/src/lib/surreal/schema/reviewer/reviewerSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { reviewerInputSchemaGen, reviewerOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { reviewerInputSchemaGen, reviewerOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new reviewer entity
-export const reviewerCreateSchema = reviewerInputSchemaGen.merge(
-	z.object({
-		id: recordId('reviewer').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const reviewerCreateSchema = reviewerInputSchemaGen.merge(z.object({
+  id: recordId("reviewer").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a reviewer entity
-export const reviewerSchema = reviewerOutputSchemaGen.merge(
-	z.object({
-		id: recordId('reviewer')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const reviewerSchema = reviewerOutputSchemaGen.merge(z.object({
+  id: recordId("reviewer"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/reviewer/reviewerTypes.ts b/src/lib/surreal/schema/reviewer/reviewerTypes.ts
index c711d542..25b9813f 100644
--- a/src/lib/surreal/schema/reviewer/reviewerTypes.ts
+++ b/src/lib/surreal/schema/reviewer/reviewerTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { reviewerCreateSchema, reviewerSchema } from './reviewerSchema.js';
+import { reviewerCreateSchema, reviewerSchema } from "./reviewerSchema.js";
 
 // the create type for table reviewer
-export type ReviewerCreate = z.input<typeof reviewerCreateSchema>;
+export type ReviewerCreate = z.input<typeof reviewerCreateSchema>
 
 // the select type for table reviewer
-export type Reviewer = z.output<typeof reviewerSchema> & { id: RecordId<string> };
+export type Reviewer = z.output<typeof reviewerSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/student/index.ts b/src/lib/surreal/schema/student/index.ts
index 377ebfd3..c0cda5e8 100644
--- a/src/lib/surreal/schema/student/index.ts
+++ b/src/lib/surreal/schema/student/index.ts
@@ -1,2 +1,2 @@
 export * from './studentSchema.js';
-export * from './studentTypes.js';
+export * from './studentTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/student/studentSchema.ts b/src/lib/surreal/schema/student/studentSchema.ts
index 15e80d83..b093060d 100644
--- a/src/lib/surreal/schema/student/studentSchema.ts
+++ b/src/lib/surreal/schema/student/studentSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { studentInputSchemaGen, studentOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { studentInputSchemaGen, studentOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new student entity
-export const studentCreateSchema = studentInputSchemaGen.merge(
-	z.object({
-		id: recordId('student').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const studentCreateSchema = studentInputSchemaGen.merge(z.object({
+  id: recordId("student").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a student entity
-export const studentSchema = studentOutputSchemaGen.merge(
-	z.object({
-		id: recordId('student')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const studentSchema = studentOutputSchemaGen.merge(z.object({
+  id: recordId("student"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/student/studentTypes.ts b/src/lib/surreal/schema/student/studentTypes.ts
index 116a1ad0..366b0528 100644
--- a/src/lib/surreal/schema/student/studentTypes.ts
+++ b/src/lib/surreal/schema/student/studentTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { studentCreateSchema, studentSchema } from './studentSchema.js';
+import { studentCreateSchema, studentSchema } from "./studentSchema.js";
 
 // the create type for table student
-export type StudentCreate = z.input<typeof studentCreateSchema>;
+export type StudentCreate = z.input<typeof studentCreateSchema>
 
 // the select type for table student
-export type Student = z.output<typeof studentSchema> & { id: RecordId<string> };
+export type Student = z.output<typeof studentSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/submission/index.ts b/src/lib/surreal/schema/submission/index.ts
index a8110d95..448b2d9d 100644
--- a/src/lib/surreal/schema/submission/index.ts
+++ b/src/lib/surreal/schema/submission/index.ts
@@ -1,2 +1,2 @@
 export * from './submissionSchema.js';
-export * from './submissionTypes.js';
+export * from './submissionTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/submission/submissionSchema.ts b/src/lib/surreal/schema/submission/submissionSchema.ts
index 61bc43c7..218544a3 100644
--- a/src/lib/surreal/schema/submission/submissionSchema.ts
+++ b/src/lib/surreal/schema/submission/submissionSchema.ts
@@ -1,26 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { submissionInputSchemaGen, submissionOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { submissionInputSchemaGen, submissionOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new submission entity
-export const submissionCreateSchema = submissionInputSchemaGen.merge(
-	z.object({
-		id: recordId('submission').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const submissionCreateSchema = submissionInputSchemaGen.merge(z.object({
+  id: recordId("submission").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a submission entity
-export const submissionSchema = submissionOutputSchemaGen.merge(
-	z.object({
-		id: recordId('submission'),
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-		score: z.number().gte(0),
-		stage: z.string()
-	})
-);
+export const submissionSchema = submissionOutputSchemaGen.merge(z.object({
+  id: recordId("submission"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/submission/submissionTypes.ts b/src/lib/surreal/schema/submission/submissionTypes.ts
index b3905832..c2160586 100644
--- a/src/lib/surreal/schema/submission/submissionTypes.ts
+++ b/src/lib/surreal/schema/submission/submissionTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { submissionCreateSchema, submissionSchema } from './submissionSchema.js';
+import { submissionCreateSchema, submissionSchema } from "./submissionSchema.js";
 
 // the create type for table submission
-export type SubmissionCreate = z.input<typeof submissionCreateSchema>;
+export type SubmissionCreate = z.input<typeof submissionCreateSchema>
 
 // the select type for table submission
-export type Submission = z.output<typeof submissionSchema> & { id: RecordId<string> };
+export type Submission = z.output<typeof submissionSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/tutor/index.ts b/src/lib/surreal/schema/tutor/index.ts
index afe94db8..3fe38a7e 100644
--- a/src/lib/surreal/schema/tutor/index.ts
+++ b/src/lib/surreal/schema/tutor/index.ts
@@ -1,2 +1,2 @@
 export * from './tutorSchema.js';
-export * from './tutorTypes.js';
+export * from './tutorTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/tutor/tutorSchema.ts b/src/lib/surreal/schema/tutor/tutorSchema.ts
index 52d02b3f..64712af4 100644
--- a/src/lib/surreal/schema/tutor/tutorSchema.ts
+++ b/src/lib/surreal/schema/tutor/tutorSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { tutorInputSchemaGen, tutorOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { tutorInputSchemaGen, tutorOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new tutor entity
-export const tutorCreateSchema = tutorInputSchemaGen.merge(
-	z.object({
-		id: recordId('tutor').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const tutorCreateSchema = tutorInputSchemaGen.merge(z.object({
+  id: recordId("tutor").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a tutor entity
-export const tutorSchema = tutorOutputSchemaGen.merge(
-	z.object({
-		id: recordId('tutor')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const tutorSchema = tutorOutputSchemaGen.merge(z.object({
+  id: recordId("tutor"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/tutor/tutorTypes.ts b/src/lib/surreal/schema/tutor/tutorTypes.ts
index c12f0ffa..7e97c486 100644
--- a/src/lib/surreal/schema/tutor/tutorTypes.ts
+++ b/src/lib/surreal/schema/tutor/tutorTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { tutorCreateSchema, tutorSchema } from './tutorSchema.js';
+import { tutorCreateSchema, tutorSchema } from "./tutorSchema.js";
 
 // the create type for table tutor
-export type TutorCreate = z.input<typeof tutorCreateSchema>;
+export type TutorCreate = z.input<typeof tutorCreateSchema>
 
 // the select type for table tutor
-export type Tutor = z.output<typeof tutorSchema> & { id: RecordId<string> };
+export type Tutor = z.output<typeof tutorSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/surreal/schema/user/index.ts b/src/lib/surreal/schema/user/index.ts
index 84d50c9b..62a25040 100644
--- a/src/lib/surreal/schema/user/index.ts
+++ b/src/lib/surreal/schema/user/index.ts
@@ -1,2 +1,2 @@
 export * from './userSchema.js';
-export * from './userTypes.js';
+export * from './userTypes.js';
\ No newline at end of file
diff --git a/src/lib/surreal/schema/user/userSchema.ts b/src/lib/surreal/schema/user/userSchema.ts
index f49c5b20..9171c945 100644
--- a/src/lib/surreal/schema/user/userSchema.ts
+++ b/src/lib/surreal/schema/user/userSchema.ts
@@ -1,24 +1,20 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
+import { z } from "zod";
 
-import { userInputSchemaGen, userOutputSchemaGen } from '../../_generated/index.js';
-import { recordId } from '../../_generated/recordSchema.js';
+import { userInputSchemaGen, userOutputSchemaGen } from "../../_generated/index.js";
+import { recordId } from "../../_generated/recordSchema.js";
 
 // payload schema for creating a new user entity
-export const userCreateSchema = userInputSchemaGen.merge(
-	z.object({
-		id: recordId('user').optional()
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const userCreateSchema = userInputSchemaGen.merge(z.object({
+  id: recordId("user").optional()
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
 
 // payload schema for fetching a user entity
-export const userSchema = userOutputSchemaGen.merge(
-	z.object({
-		id: recordId('user')
-		// add your custom fields here, which are not part of SurrealDB table schema
-		// they are not overwritten by the next run
-	})
-);
+export const userSchema = userOutputSchemaGen.merge(z.object({
+  id: recordId("user"),
+  // add your custom fields here, which are not part of SurrealDB table schema
+  // they are not overwritten by the next run
+      }))
diff --git a/src/lib/surreal/schema/user/userTypes.ts b/src/lib/surreal/schema/user/userTypes.ts
index d3306b9e..c2c216db 100644
--- a/src/lib/surreal/schema/user/userTypes.ts
+++ b/src/lib/surreal/schema/user/userTypes.ts
@@ -1,12 +1,13 @@
 /* Place your custom changes here */
 
-import { z } from 'zod';
-import { type RecordId } from 'surrealdb';
+import { z } from "zod";
+import { type RecordId} from "surrealdb";
 
-import { userCreateSchema, userSchema } from './userSchema.js';
+import { userCreateSchema, userSchema } from "./userSchema.js";
 
 // the create type for table user
-export type UserCreate = z.input<typeof userCreateSchema>;
+export type UserCreate = z.input<typeof userCreateSchema>
 
 // the select type for table user
-export type User = z.output<typeof userSchema> & { id: RecordId<string> };
+export type User = z.output<typeof userSchema> & {id: RecordId<string>}
+      
\ No newline at end of file
diff --git a/src/lib/zod.ts b/src/lib/zod.ts
index 2ef3de1b..dbba2b37 100644
--- a/src/lib/zod.ts
+++ b/src/lib/zod.ts
@@ -1,100 +1,5 @@
 import z from 'zod';
-import { RecordId, StringRecordId } from 'surrealdb';
-
-type TableRecordId<T extends string> = RecordId<T> | StringRecordId | `${T}:${string}`;
-
-export function recordId<Table extends string = string>(table?: Table) {
-	const tableRegex = table ? table : '[A-Za-z_][A-Za-z0-9_]*';
-	const idRegex = '[^:]+';
-	const fullRegex = new RegExp(`^${tableRegex}:${idRegex}$`);
-
-	return z
-		.union([
-			z
-				.custom<RecordId<string>>((val): val is RecordId<string> => val instanceof RecordId)
-				.refine((val): val is RecordId<Table> => !table || val.tb === table, {
-					message: table ? `RecordId must be of type '${table}'` : undefined
-				}),
-			z
-				.custom<StringRecordId>((val): val is StringRecordId => val instanceof StringRecordId)
-				.refine((val) => !table || val.rid.startsWith(`${table}:`), {
-					message: table ? `StringRecordId must start with '${table}:'` : undefined
-				}),
-			z.string().regex(fullRegex, {
-				message: table
-					? `Invalid record ID format. Must be '${table}:id'`
-					: "Invalid record ID format. Must be 'table:id'"
-			})
-		])
-		.transform((val): TableRecordId<Table> => {
-			if (typeof val === 'string') {
-				return new StringRecordId(val) as TableRecordId<Table>;
-			}
-			return val as TableRecordId<Table>;
-		});
-}
-
-export const role = z.enum(['admin', 'reviewer', 'tutor', 'student']);
-export const roles = z.union([z.array(role), z.set(role)]).transform((val) => {
-	return val instanceof Set ? val : new Set(val);
-});
-
-export type Role = z.infer<typeof role>;
-export type Roles = z.infer<typeof roles>;
-
-// The select schema for table user
-// const userRecordSchema = z.object({
-// 	id: recordId('user'),
-// 	name: z.string(),
-// 	email: z.string().email(),
-// 	enabled: z.boolean(),
-// 	password_hash: z.string().optional(),
-// 	roles: roles,
-// 	activation_token: z.string().optional(),
-// 	activation_expires: z.date().optional()
-// });
-
-// export const userSchema = userRecordSchema.transform((user) => ({
-// 	...user,
-// 	id: user.id.toString(),
-// 	roles: Array.from(user.roles)
-// }));
-
-// export type User = z.infer<typeof userSchema>;
-
-export const userSignUpSchema = z.object({
-	name: z.string().min(3),
-	email: z.string().email(),
-	// enabled: z.boolean().optional(),
-	password: z.string()
-	// roles: roles.optional()
-});
-
-export type SignUpCredentials = z.infer<typeof userSignUpSchema>;
-
-export const userSignInSchema = z.object({
-	email: z.string().email(),
-	password: z.string()
-});
-
-export type SignInCredentials = z.infer<typeof userSignInSchema>;
-
-export const createUserSchema = z.object({
-	name: z.string().min(3),
-	email: z.string().email(),
-	roles: z.array(role)
-});
-
-export const activateAccountSchema = z.object({
-	token: z.string(),
-	password: z.string().min(8)
-});
-
-export const deleteUserSchema = z.object({ userId: z.string() });
-
-export type CreateUser = z.infer<typeof createUserSchema>;
-export type DeleteUser = z.infer<typeof deleteUserSchema>;
-export type ActivateAccount = z.infer<typeof activateAccountSchema>;
+import { recordId } from './surreal/_generated/recordSchema';
 
 export const tokenInfoSchema = z.object({
 	AC: z.string().optional(),
diff --git a/src/routes/(app)/debug/editor/+page.server.ts b/src/routes/(app)/debug/editor/+page.server.ts
index 50c9aad3..d5bd2275 100644
--- a/src/routes/(app)/debug/editor/+page.server.ts
+++ b/src/routes/(app)/debug/editor/+page.server.ts
@@ -1,10 +1,28 @@
-import { jsonify } from 'surrealdb';
+import { jsonify, RecordId } from 'surrealdb';
 import type { PageServerLoad } from './$types';
-import { getEvaluation, getSubmission } from './db';
+import { getDb } from '$lib/surreal.svelte';
+import { type Annotation, type Evaluation, type Submission } from '$lib/surreal/schema';
 
+// TODO maybe stream promises to client?
 export const load: PageServerLoad = async (event) => {
-	// TODO maybe stream promises to client?
-	const submission = await getSubmission();
-	const evaluation = await getEvaluation();
-	return { submission: jsonify(submission), evaluation: jsonify(evaluation) };
+	const db = await getDb();
+
+	const dbgSubId = new RecordId('submission', 'dbg1');
+	const dbgEvalId = new RecordId('evaluation', 'dbg1');
+
+	const submission = await db.select<Submission>(dbgSubId);
+
+	const evaluation = await db.select<Evaluation>(dbgEvalId);
+
+	// TODO fetch together with evaluation?
+	const [annotations] = await db.query<[Annotation[]]>('SELECT * FROM $evaluation<-annotation', {
+		evaluation: dbgEvalId
+	});
+	// console.log(annotations);
+
+	return {
+		submission: jsonify(submission),
+		evaluation: jsonify(evaluation),
+		annotations: jsonify(annotations)
+	};
 };
diff --git a/src/routes/(app)/debug/editor/+page.svelte b/src/routes/(app)/debug/editor/+page.svelte
index 4d45402a..49c9cc3f 100644
--- a/src/routes/(app)/debug/editor/+page.svelte
+++ b/src/routes/(app)/debug/editor/+page.svelte
@@ -2,7 +2,6 @@
 	import type { PageProps } from './$types';
 	import { initDbgData } from './db';
 	import { Editor } from './Editor';
-	import CodeBlock from './Editor/CodeBlock.svelte';
 
 	let { data }: PageProps = $props();
 </script>
@@ -15,7 +14,15 @@
 	}}>Init</button
 >
 
-<Editor submission={data.submission} evaluation={data.evaluation} />
+{#if data.submission && data.evaluation}
+	<Editor
+		submission={data.submission}
+		evaluation={data.evaluation}
+		annotations={data.annotations}
+	/>
+{:else}
+	<p>No submission/evaluation data</p>
+{/if}
 
 <style>
 </style>
diff --git a/src/routes/(app)/debug/editor/Editor/CodeBlock.svelte b/src/routes/(app)/debug/editor/Editor/CodeBlock.svelte
index 8d8650ed..27d356ee 100644
--- a/src/routes/(app)/debug/editor/Editor/CodeBlock.svelte
+++ b/src/routes/(app)/debug/editor/Editor/CodeBlock.svelte
@@ -39,18 +39,36 @@
 		preClasses = ''
 	}: CodeBlockProps = $props();
 
-	const generatedHtml = shiki.codeToHtml(code, {
-		structure: 'classic', // one span per line, one span per token in a line
-		lang,
-		theme,
-		//meta:
-		transformers: [sourceMappingTransformer],
-		decorations
-	});
+	const generatedHtml = $derived(
+		shiki.codeToHtml(code, {
+			structure: 'classic', // one span per line, one span per token in a line
+			lang,
+			theme,
+			//meta:
+			transformers: [sourceMappingTransformer],
+			decorations
+		})
+	);
 
 	// internal reference to element containing generated HTML
 	let containerElement: HTMLElement;
 
+	$effect(() => {
+		// register dependency
+		generatedHtml;
+
+		if (!containerElement) return;
+
+		// find the actual <pre> element generated by shiki
+		const preElement = containerElement.querySelector('pre.shiki');
+		if (preElement) {
+			element = preElement as HTMLPreElement;
+		}
+		console.log(preElement);
+		console.log(containerElement);
+	});
+
+	/*
 	onMount(() => {
 		if (!containerElement) return;
 
@@ -59,7 +77,10 @@
 		if (preElement) {
 			element = preElement as HTMLPreElement;
 		}
+		console.log(preElement);
+		console.log(containerElement);
 	});
+	*/
 </script>
 
 <div
diff --git a/src/routes/(app)/debug/editor/Editor/Editor.svelte b/src/routes/(app)/debug/editor/Editor/Editor.svelte
index d7b43b1f..4c72bc24 100644
--- a/src/routes/(app)/debug/editor/Editor/Editor.svelte
+++ b/src/routes/(app)/debug/editor/Editor/Editor.svelte
@@ -4,8 +4,12 @@
 	import type { DOMSelectionInfo, EditorProps, SelectionState } from './types';
 	import { browser } from '$app/environment';
 	import { selectionInElement, domSelectionToSourceRange } from './dom';
+	import type { Annotation, AnnotationCreate } from '$lib/surreal/schema';
+	import { getDb } from '$lib/surreal.svelte';
+	import { jsonify, StringRecordId, Uuid } from 'surrealdb';
+	import { db } from '../db';
 
-	let { submission, evaluation }: EditorProps = $props();
+	let { submission, evaluation, annotations }: EditorProps = $props();
 
 	// <pre> generated by shiki
 	let codeElement: HTMLPreElement | null = $state(null);
@@ -13,20 +17,60 @@
 	let domSelection: DOMSelectionInfo | null = $state(null);
 	let sourceMapping = $state<SelectionState | null>(null);
 
-	let selectionChangeTimeout: number | null = null;
-
-	function handleSelectionChange() {
-		/*
-		if (selectionChangeTimeout) {
-			clearTimeout(selectionChangeTimeout);
-		}
+	// annotation form
+	let currentAnnotation = $state<Partial<AnnotationCreate> | null>({
+		type: 'range',
+		content: '',
+		meta: { scoreDelta: 0.0 },
+		visual: { color: '#f6d32d' },
+		in: new StringRecordId('tutor:dbg0'),
+		out: new StringRecordId(evaluation.id)
+	});
 
-		// debounce selection change events
-		selectionChangeTimeout = setTimeout(() => {
-			updateSelection();
-		})
-		*/
+	// TODO clean up state flow (pass annotations prop as state)
+	let _annotations: typeof annotations = $state(annotations);
+
+	// TODO add current annotation decoration
+	// TODO handle lines
+	// TODO use actual background color
+	// TODO memoize?
+	const decorations = $derived(
+		_annotations
+			.filter((a) => a.type === 'range')
+			.map((a) => ({
+				start: a.range.start?.offset ?? 0, // TODO
+				end: a.range.end?.offset ?? 0,
+				properties: { class: 'bg-amber-200 hover:bg-fuchsia-500' }
+			}))
+	);
+	/*
+	const decorations = $derived.by(() => {
+		annotations
+			.filter((a) => a.type === 'range')
+			.map((a) => ({
+				start: a.range.start?.offset,
+				end: a.range.end?.offset,
+				properties: { class: 'bg-amber-200 hover:bg-fuchsia-500' }
+			}));
+	});
+	*/
+	$inspect(_annotations);
+	$inspect(decorations);
+	$inspect(currentAnnotation);
+	$inspect(sourceMapping);
+
+	async function saveAnnotation() {
+		const db = await getDb();
+
+		const result = await db.insertRelation('annotation', {
+			range: { start: sourceMapping?.anchor, end: sourceMapping?.focus },
+			...currentAnnotation
+		});
+		console.log(result);
+	}
 
+	function handleSelectionChange() {
+		// TODO: debounce selectionchange events?
 		updateSelection();
 	}
 
@@ -56,37 +100,105 @@
 		sourceMapping = domSelectionToSourceRange(selection, codeElement);
 	}
 
-	onMount(() => {
+	let liveAnnotationQueryId: Uuid;
+	onMount(async () => {
 		document.addEventListener('selectionchange', handleSelectionChange);
+
+		liveAnnotationQueryId = await db.live<Annotation>(
+			'annotation',
+			(action, result) => {
+				console.log(action);
+				console.log(result);
+
+				if (result === 'killed') {
+					console.log(`live query killed: ${liveAnnotationQueryId}`);
+					return;
+				}
+				if (result === 'disconnected') {
+					// TODO reconnect
+					console.log(`live query disconnected: ${liveAnnotationQueryId}`);
+					return;
+				}
+
+				// doesn't concern us
+				if (result.out.toString() !== evaluation.id) return;
+				console.log(result.out.toString() === evaluation.id);
+
+				// add to local annotation list until next complete sync
+				if (action === 'CREATE') _annotations.push(jsonify(result));
+				if (action === 'DELETE') return; // TODO
+				if (action === 'UPDATE') return; // TODO
+			},
+			false
+		);
 	});
-	onDestroy(() => {
+	onDestroy(async () => {
 		if (!browser) return;
 		document.removeEventListener('selectionchange', handleSelectionChange);
-		if (selectionChangeTimeout) {
-			clearTimeout(selectionChangeTimeout);
+
+		if (liveAnnotationQueryId) {
+			await db.kill(liveAnnotationQueryId);
 		}
 	});
 </script>
 
-<div class="editor-container">
-	<CodeBlock
-		bind:element={codeElement}
-		code={submission.code}
-		decorations={[
-			{ start: 279, end: 283, properties: { class: 'bg-amber-200' } },
-			{ start: 358, end: 376, properties: { class: 'bg-amber-200' } }
-		]}
-	/>
-
-	{#if domSelection}
-		<div class="debug-panel">
-			<h3>DOM Selection</h3>
-			<pre>{JSON.stringify(domSelection, null, 2)}</pre>
-
-			<h3>Source Mapping</h3>
-			<pre>{JSON.stringify(sourceMapping, null, 2)}</pre>
+<div class="grid grid-cols-[auto_1fr]">
+	<main class="editor-container bg-green-500">
+		<CodeBlock bind:element={codeElement} code={submission.code} {decorations} />
+
+		{#if domSelection}
+			<div class="debug-panel">
+				<h3>DOM Selection</h3>
+				<pre>{JSON.stringify(domSelection, null, 2)}</pre>
+
+				<h3>Source Mapping</h3>
+				<pre>{JSON.stringify(sourceMapping, null, 2)}</pre>
+			</div>
+		{/if}
+	</main>
+	<aside class="">
+		<div class="mx-auto w-full max-w-md space-y-4">
+			<select class="select" bind:value={currentAnnotation!.type}>
+				<option value="document">Document</option>
+				<option value="line">Line</option>
+				<option value="range">Range</option>
+			</select>
+			<label class="label">
+				<span class="label-text">Comment</span>
+				<input
+					class="input"
+					type="text"
+					placeholder="..."
+					bind:value={currentAnnotation!.content}
+				/>
+			</label>
+			<!-- Range -->
+			<label class="label">
+				<span class="label-text">Score Delta: {currentAnnotation!.meta!.scoreDelta}</span>
+				<input
+					class="input"
+					type="range"
+					bind:value={currentAnnotation!.meta!.scoreDelta}
+					min={-10}
+					max={10}
+					step={0.25}
+				/>
+			</label>
+			<!-- Color -->
+			<!-- TODO: convert to mini-component for reactive value -->
+			<div class="grid grid-cols-[auto_1fr] gap-2">
+				<input class="input" type="color" bind:value={currentAnnotation!.visual!.color} />
+				<input
+					class="input"
+					type="text"
+					bind:value={currentAnnotation!.visual!.color}
+					readonly
+					tabindex="-1"
+				/>
+			</div>
 		</div>
-	{/if}
+		<button class="btn preset-filled-primary-500" onclick={saveAnnotation}>Save</button>
+	</aside>
 </div>
 
 <style>
diff --git a/src/routes/(app)/debug/editor/Editor/schema.ts b/src/routes/(app)/debug/editor/Editor/schema.ts
index 0f5a57ec..8d151dab 100644
--- a/src/routes/(app)/debug/editor/Editor/schema.ts
+++ b/src/routes/(app)/debug/editor/Editor/schema.ts
@@ -5,25 +5,10 @@ const zeroIdx = z.number().int().gte(0);
 export const sourcePosition = z.object({ line: zeroIdx, column: zeroIdx });
 export type SourcePosition = z.infer<typeof sourcePosition>;
 
-export const sourceSelection = z.object({
-	type: z.union([z.literal('None'), z.literal('Caret'), z.literal('Range')]),
-	start: sourcePosition,
-	end: sourcePosition,
-	text: z.string(),
-	color: z.string().optional() // TODO: validate
-});
-export type SourceSelection = z.infer<typeof sourceSelection>;
+// export const annotation = z.discriminatedUnion('kind', [
+// 	annotationCommonFields.extend({ kind: z.literal('line'), line: z.number().gte(0) }),
+// 	annotationCommonFields.extend({ kind: z.literal('range'), selection: sourceSelection }),
+// 	annotationCommonFields.extend({ kind: z.literal('global') })
+// ]);
 
-const annotationCommonFields = z.object({
-	comment: z.string(),
-	scoreDelta: z.number(),
-	createdAt: z.string().datetime()
-});
-
-export const annotation = z.discriminatedUnion('kind', [
-	annotationCommonFields.extend({ kind: z.literal('line'), line: z.number().gte(0) }),
-	annotationCommonFields.extend({ kind: z.literal('range'), selection: sourceSelection }),
-	annotationCommonFields.extend({ kind: z.literal('global') })
-]);
-
-export type Annotation = z.infer<typeof annotation>;
+// export type Annotation = z.infer<typeof annotation>;
diff --git a/src/routes/(app)/debug/editor/Editor/todo.md b/src/routes/(app)/debug/editor/Editor/todo.md
index b59c5e32..5c224690 100644
--- a/src/routes/(app)/debug/editor/Editor/todo.md
+++ b/src/routes/(app)/debug/editor/Editor/todo.md
@@ -74,10 +74,9 @@ The primary users are academic tutors with varying levels of technical proficien
 
 The editor implements a hierarchical composition pattern with:
 
-- Core text rendering engine ($state-driven document model)
-- Selection management subsystem (leveraging Svelte actions)
+- Core text rendering engine
+- Selection management subsystem
 - Annotation overlay system (DOM-synchronized positional model)
-- Command interface layer (for keybindings and programmatic control)
 
 ## Architectural Principles and Design Philosophy
 
@@ -124,7 +123,6 @@ The document model follows a hybrid approach with two synchronized representatio
 ## Selection State Management
 
 - Selection represented as a positional range with the following structure:
-
   ```typescript
   // Mapped from a DOM `Selection`, where anchor and focus are `Node`s, to a source selection
   interface SelectionState {
@@ -142,7 +140,6 @@ The document model follows a hybrid approach with two synchronized representatio
   	offset: number; // Absolute character offset in source document
   }
   ```
-
 - Separate overlay selection state for annotation range visualization
 - DOM selection synchronized via bidirectional mapping functions
 
@@ -194,7 +191,6 @@ The document model follows a hybrid approach with two synchronized representatio
   	};
   }
   ```
-
 - Position references use both line/column and absolute character offsets for stability
 - Annotations stored in an indexed collection for efficient lookup by position
 
diff --git a/src/routes/(app)/debug/editor/Editor/types.ts b/src/routes/(app)/debug/editor/Editor/types.ts
index 7f6725ad..f63e88f6 100644
--- a/src/routes/(app)/debug/editor/Editor/types.ts
+++ b/src/routes/(app)/debug/editor/Editor/types.ts
@@ -1,10 +1,11 @@
-import type { Evaluation, Submission } from '$lib/surreal/schema';
+import type { Annotation, Evaluation, Submission } from '$lib/surreal/schema';
 import type { DecorationItem, DecorationOptions, ThemedToken } from 'shiki';
 import type { jsonify } from 'surrealdb';
 
 export interface EditorProps {
 	submission: ReturnType<typeof jsonify<Submission>>;
 	evaluation: ReturnType<typeof jsonify<Evaluation>>;
+	annotations: ReturnType<typeof jsonify<Annotation[]>>;
 }
 
 export interface CodeBlockProps {
@@ -50,7 +51,7 @@ export interface Position {
 	offset: number; // Absolute character offset in source document
 }
 
-export interface DocumentLine {
+interface DocumentLine {
 	id: string; // Stable line identifier
 	content: string; // Line content
 	lineNumber: number; // 1-based line number
@@ -63,45 +64,45 @@ export interface DocumentLine {
 	};
 }
 
-export interface BaseAnnotation {
-	type: 'document' | 'line' | 'range'; // Annotation scope
-	id: string;
-	content: string; // Structured annotation content
-	metadata: {
-		author: string; // Author identifier
-		createdAt: string; // Creation timestamp, ISO 8601
-		scoreDelta?: number; // Optional score impact
-		tags?: string[]; // Optional categorization
-	};
-}
+// interface BaseAnnotation {
+// 	type: 'document' | 'line' | 'range'; // Annotation scope
+// 	id: string;
+// 	content: string; // Structured annotation content
+// 	metadata: {
+// 		author: string; // Author identifier
+// 		createdAt: string; // Creation timestamp, ISO 8601
+// 		scoreDelta?: number; // Optional score impact
+// 		//tags?: string[]; // Optional categorization
+// 	};
+// }
 
-export interface DocumentAnnotation extends BaseAnnotation {
-	type: 'document';
-	visualSettings?: {
-		color?: string;
-	};
-}
+// interface DocumentAnnotation extends BaseAnnotation {
+// 	type: 'document';
+// 	visualSettings?: {
+// 		color?: string;
+// 	};
+// }
 
-export interface LineAnnotation extends BaseAnnotation {
-	type: 'line';
-	line: Position; // column of Position is 0, i.e. first on line
-	visualSettings?: {
-		color?: string; // line highlight color
-		priority?: number;
-	};
-}
+// interface LineAnnotation extends BaseAnnotation {
+// 	type: 'line';
+// 	line: Position; // column of Position is last on line
+// 	visualSettings?: {
+// 		color?: string; // line highlight color
+// 		priority?: number;
+// 	};
+// }
 
-export interface RangeAnnotation extends BaseAnnotation {
-	type: 'range';
-	range: {
-		start: Position;
-		end: Position;
-	};
-	visualSettings?: {
-		color?: string;
-		style?: 'solid' | 'dashed' | 'dotted'; // underline style
-		priority?: number;
-	};
-}
+// interface RangeAnnotation extends BaseAnnotation {
+// 	type: 'range';
+// 	range: {
+// 		start: Position;
+// 		end: Position;
+// 	};
+// 	visualSettings?: {
+// 		color?: string;
+// 		style?: 'solid' | 'dashed' | 'dotted'; // underline style
+// 		priority?: number;
+// 	};
+// }
 
-export type Annotation = DocumentAnnotation | LineAnnotation | RangeAnnotation;
+// type Annotation = DocumentAnnotation | LineAnnotation | RangeAnnotation;
diff --git a/src/routes/(app)/debug/editor/db.ts b/src/routes/(app)/debug/editor/db.ts
index ef9f40e4..7ce085c8 100644
--- a/src/routes/(app)/debug/editor/db.ts
+++ b/src/routes/(app)/debug/editor/db.ts
@@ -1,10 +1,5 @@
 import { getDb } from '$lib/surreal.svelte';
-import {
-	evaluationSchema,
-	submissionSchema,
-	type Evaluation,
-	type Submission
-} from '$lib/surreal/schema';
+import { evaluationSchema, submissionSchema } from '$lib/surreal/schema';
 import { RecordId } from 'surrealdb';
 
 export const db = await getDb();
@@ -13,11 +8,19 @@ const dbgSubId = new RecordId('submission', 'dbg1');
 const dbgEvalId = new RecordId('evaluation', 'dbg1');
 
 export async function getSubmission() {
-	return submissionSchema.parse(await db.select(dbgSubId));
+	const submission = await db.select(dbgSubId);
+
+	return submission ? submissionSchema.parse(submission) : undefined;
 }
 
 export async function getEvaluation() {
-	return evaluationSchema.parse(await db.select(dbgEvalId));
+	const evaluation = await db.select(dbgEvalId);
+
+	return evaluation ? evaluationSchema.parse(evaluation) : undefined;
+}
+
+export async function getAnnotations() {
+	return await db.query('SELECT * FROM $evaluation<-annotation', { evaluation: dbgEvalId });
 }
 
 export async function initDbgData() {
@@ -58,12 +61,12 @@ export async function initDbgData() {
 		}
 	);
 
-	console.log(submission);
+	// console.log(submission);
 
 	const evaluation = await db.relate(new RecordId('tutor', 'dbg1'), dbgEvalId, dbgSubId, {
 		final: false,
 		score: 0
 	});
 
-	console.log(evaluation);
+	// console.log(evaluation);
 }
diff --git a/surql-gen.json b/surql-gen.json
index 70581145..1755859f 100644
--- a/surql-gen.json
+++ b/surql-gen.json
@@ -9,4 +9,4 @@
 	"generateClient": false,
 	"lib": "surrealdb",
 	"surrealImage": "surrealdb/surrealdb:latest"
-}
+}
\ No newline at end of file
-- 
GitLab