feat(阶段3): oj 侧端点铺开(基线提交,未经评审)
由外部 agent (Codex) 在本会话额度中断期间完成。原样提交作为基线, 后续修复单独成 commit,便于区分与回退。 覆盖 oj 侧 65 个端点,新增 9 组路由(account/achievement/ai/classroom/ content/contest/flowchart/problemset/site)与对应 Zod 契约。 已核验:tsc --noEmit 退出码 0;API 可启动;/api/problems 返回真实数据; judge 与 flowchart worker 均 ready。 未核验:权限边界与数据泄露,评审进行中。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
71
packages/contract/src/flowchart.ts
Normal file
71
packages/contract/src/flowchart.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { paginatedSchema } from "./common"
|
||||
|
||||
export const flowchartStatusSchema = z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)])
|
||||
|
||||
export const createFlowchartRequestSchema = z.object({
|
||||
problemId: z.number().int().positive(),
|
||||
mermaidCode: z.string().trim().min(1).max(50_000).refine(
|
||||
(value) => value.split("\n").filter((line) => line.trim()).length <= 200,
|
||||
"Flowchart is too complex",
|
||||
),
|
||||
flowchartData: z.record(z.string(), z.unknown()).default({}),
|
||||
})
|
||||
|
||||
export const flowchartSubmissionSchema = z.object({
|
||||
id: z.string(),
|
||||
username: z.string(),
|
||||
problemId: z.number().int(),
|
||||
mermaidCode: z.string(),
|
||||
flowchartData: z.record(z.string(), z.unknown()),
|
||||
status: flowchartStatusSchema,
|
||||
createTime: z.string(),
|
||||
aiScore: z.number().nullable(),
|
||||
aiGrade: z.string().nullable(),
|
||||
aiFeedback: z.string().nullable(),
|
||||
aiSuggestions: z.string().nullable(),
|
||||
aiCriteriaDetails: z.record(z.string(), z.unknown()),
|
||||
aiProvider: z.string(),
|
||||
aiModel: z.string(),
|
||||
processingTime: z.number().nullable(),
|
||||
evaluationTime: z.string().nullable(),
|
||||
})
|
||||
|
||||
export const flowchartListItemSchema = z.object({
|
||||
id: z.string(),
|
||||
username: z.string(),
|
||||
problem: z.string(),
|
||||
problemTitle: z.string(),
|
||||
status: flowchartStatusSchema,
|
||||
createTime: z.string(),
|
||||
aiScore: z.number().nullable(),
|
||||
aiGrade: z.string().nullable(),
|
||||
aiProvider: z.string(),
|
||||
aiModel: z.string(),
|
||||
processingTime: z.number().nullable(),
|
||||
evaluationTime: z.string().nullable(),
|
||||
showLink: z.boolean(),
|
||||
})
|
||||
|
||||
export const flowchartListSchema = paginatedSchema(flowchartListItemSchema)
|
||||
export const createFlowchartResponseSchema = z.object({ submissionId: z.string(), status: z.literal("pending") })
|
||||
export const flowchartCurrentSchema = z.object({ count: z.number().int(), score: z.number(), grade: z.string() })
|
||||
export const flowchartDetailSchema = z.object({ submission: flowchartSubmissionSchema.nullable(), count: z.number().int() })
|
||||
|
||||
export const flowchartUpdateSchema = z.object({
|
||||
type: z.enum([
|
||||
"flowchart_evaluation_completed",
|
||||
"flowchart_evaluation_failed",
|
||||
"flowchart_evaluation_update",
|
||||
]),
|
||||
submission_id: z.string(),
|
||||
score: z.number().optional(),
|
||||
grade: z.string().optional(),
|
||||
feedback: z.string().optional(),
|
||||
suggestions: z.string().optional(),
|
||||
criteriaDetails: z.unknown().optional(),
|
||||
error: z.string().optional(),
|
||||
})
|
||||
|
||||
export type FlowchartUpdate = z.infer<typeof flowchartUpdateSchema>
|
||||
Reference in New Issue
Block a user