feat(lesson-preparation): add AI evaluation, analytics, attachments, calendar, comments, review, substitutes, formative, and version diff
- Add actions-ai-evaluation, actions-analytics, actions-attachments, actions-calendar, actions-comments, actions-formative, actions-questions, actions-review, actions-substitutes - Add corresponding data-access layers for each new action module - Add calendar-view, curriculum-map-view, version-diff-viewer components - Add editor-slice, selection-slice, version-slice hooks for state management - Add document-diff and scope-check lib utilities - Add default-question-service and external-questions-bridge services
This commit is contained in:
@@ -7,23 +7,16 @@ import { db } from "@/shared/db";
|
||||
import { lessonPlanTemplates, lessonPlans } from "@/shared/db/schema";
|
||||
import { SYSTEM_TEMPLATES } from "./constants";
|
||||
import { normalizeDocument, LessonPlanDataError } from "./data-access";
|
||||
import {
|
||||
normalizeTemplateBlocks,
|
||||
isTemplateType,
|
||||
isTemplateScope,
|
||||
} from "./lib/type-guards";
|
||||
import type {
|
||||
LessonPlanTemplate,
|
||||
TemplateBlockSkeleton,
|
||||
TemplateType,
|
||||
TemplateScope,
|
||||
} from "./types";
|
||||
|
||||
// ---- 类型守卫:安全地将 DB string 收窄为联合类型 ----
|
||||
const TEMPLATE_TYPES = ["system", "personal"] as const;
|
||||
function isTemplateType(v: string): v is TemplateType {
|
||||
return (TEMPLATE_TYPES as readonly string[]).includes(v);
|
||||
}
|
||||
const TEMPLATE_SCOPES = ["regular", "review", "experiment", "inquiry", "blank", "custom"] as const;
|
||||
function isTemplateScope(v: string): v is TemplateScope {
|
||||
return (TEMPLATE_SCOPES as readonly string[]).includes(v);
|
||||
}
|
||||
|
||||
// ---- 类型映射:Drizzle 行 → LessonPlanTemplate(Date → ISO string)----
|
||||
function mapRowToTemplate(row: {
|
||||
id: string;
|
||||
@@ -40,8 +33,8 @@ function mapRowToTemplate(row: {
|
||||
name: row.name,
|
||||
type: isTemplateType(row.type) ? row.type : "personal",
|
||||
scope: isTemplateScope(row.scope) ? row.scope : "custom",
|
||||
// 从 unknown 转换为 TemplateBlockSkeleton[](DB JSON 字段)
|
||||
blocks: row.blocks as LessonPlanTemplate["blocks"],
|
||||
// P1 修复:使用 normalizeTemplateBlocks 安全转换 DB JSON 字段,替代 as 断言
|
||||
blocks: normalizeTemplateBlocks(row.blocks),
|
||||
creatorId: row.creatorId,
|
||||
createdAt: row.createdAt.toISOString(),
|
||||
updatedAt: row.updatedAt.toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user