Skip to content
Snippets Groups Projects
Commit 70ffe648 authored by Linus Keiser's avatar Linus Keiser :speech_balloon:
Browse files

--wip--

parent 7bf93938
No related branches found
No related tags found
No related merge requests found
Showing
with 413 additions and 0 deletions
// ====================
// 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 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();
// 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();
// ====================
// 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 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();
// 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();
// ====================
// DO NOT EDIT THIS FILE!
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from "zod";
// the create schema for table exercise_group
export const exerciseGroupInputSchemaGen = z.object({
}).passthrough();
// the select schema for table exercise_group
export const exerciseGroupOutputSchemaGen = z.object({
}).passthrough();
// ====================
// 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 has_account
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 * from './assignment/assignmentSchemaGen.js';
export * from './evaluation/evaluationSchemaGen.js';
export * from './exerciseGroup/exerciseGroupSchemaGen.js';
export * from './hasAccount/hasAccountSchemaGen.js';
export * from './memberOf/memberOfSchemaGen.js';
export * from './module/moduleSchemaGen.js';
export * from './review/reviewSchemaGen.js';
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';
\ No newline at end of file
// ====================
// 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 member_of
export const memberOfInputSchemaGen = z.object({
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')
});
// ====================
// DO NOT EDIT THIS FILE!
// This file is autogenerated and will be overwritten during generation!
// ====================
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();
// 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();
import z from 'zod'
import { RecordId, StringRecordId } from 'surrealdb'
const RecordIdValue = z.union([z.string(), z.number(), z.bigint(), z.record(z.unknown()), z.array(z.unknown())])
type RecordIdValue = z.infer<typeof RecordIdValue>
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'",
}),
z.object({
rid: z.string().regex(fullRegex),
}),
z
.object({
tb: z.string(),
id: z.union([z.string(), z.number(), z.record(z.unknown())]),
})
.refine(val => !table || val.tb === table, {
message: table ? `RecordId must be of type '${table}'` : undefined,
}),
])
.transform((val): RecordId<Table> | StringRecordId => {
if (val instanceof RecordId) {
return val as RecordId<Table>
}
if (val instanceof StringRecordId) {
return val
}
if (typeof val === 'string') {
const [tb, ...idParts] = val.split(':')
const id = idParts.join(':')
if (!tb || !id) throw new Error('Invalid record ID string format')
return new StringRecordId(val)
}
if ('rid' in val) {
const [tb, ...idParts] = val.rid.split(':')
const id = idParts.join(':')
if (!tb || !id) throw new Error('Invalid rid object format')
return new StringRecordId(val.rid)
}
if ('tb' in val && 'id' in val) {
return new RecordId(val.tb, val.id) as RecordId<Table>
}
throw new Error('Invalid input for RecordId')
})
\ No newline at end of file
// ====================
// 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 review
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();
// ====================
// DO NOT EDIT THIS FILE!
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from "zod";
// the create schema for table reviewer
export const reviewerInputSchemaGen = z.object({
}).passthrough();
// the select schema for table reviewer
export const reviewerOutputSchemaGen = z.object({
}).passthrough();
// ====================
// DO NOT EDIT THIS FILE!
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from "zod";
// the create schema for table student
export const studentInputSchemaGen = z.object({
alias: z.string()
}).passthrough();
// the select schema for table student
export const studentOutputSchemaGen = z.object({
alias: z.string()
}).passthrough();
// ====================
// 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 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();
// 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();
// ====================
// DO NOT EDIT THIS FILE!
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from "zod";
// the create schema for table tutor
export const tutorInputSchemaGen = z.object({
}).passthrough();
// the select schema for table tutor
export const tutorOutputSchemaGen = z.object({
}).passthrough();
// ====================
// DO NOT EDIT THIS FILE!
// This file is autogenerated and will be overwritten during generation!
// ====================
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()
});
// 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()
});
/* Place your custom changes here */
import { z } from "zod";
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
}))
// 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
}))
/* Place your custom changes here */
import { z } from "zod";
import { type RecordId} from "surrealdb";
import { assignmentCreateSchema, assignmentSchema } from "./assignmentSchema.js";
// the create type for table assignment
export type AssignmentCreate = z.input<typeof assignmentCreateSchema>
// the select type for table assignment
export type Assignment = z.output<typeof assignmentSchema> & {id: RecordId<string>}
\ No newline at end of file
export * from './assignmentSchema.js';
export * from './assignmentTypes.js';
\ No newline at end of file
/* Place your custom changes here */
import { z } from "zod";
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
}))
// 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
}))
/* Place your custom changes here */
import { z } from "zod";
import { type RecordId} from "surrealdb";
import { evaluationCreateSchema, evaluationSchema } from "./evaluationSchema.js";
// the create type for table evaluation
export type EvaluationCreate = z.input<typeof evaluationCreateSchema>
// the select type for table evaluation
export type Evaluation = z.output<typeof evaluationSchema> & {id: RecordId<string>}
\ No newline at end of file
export * from './evaluationSchema.js';
export * from './evaluationTypes.js';
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment