feat: productionize learning engine and classroom

This commit is contained in:
inman
2026-08-16 21:44:52 +08:00
parent 2d04197f3f
commit ba35adfbfa
124 changed files with 9071 additions and 796 deletions

View File

@@ -21,6 +21,11 @@ import {
CourseMutationInProgressError,
isCoursePublishing,
} from '@/lib/course-framework/publish-state';
import { proxyLargeCourseControlToEngine } from '@/lib/makelore-runtime/ops-engine-control';
import {
assertLearningCourseMutable,
FrozenLearningCourseMutationError,
} from '@/lib/makelore-course/immutability';
const log = createLogger('Framework Regenerate API');
@@ -28,7 +33,7 @@ export async function POST(
req: NextRequest,
{ params }: { params: Promise<{ courseId: string }> },
) {
const denied = requireOpsAccess(req);
const denied = await requireOpsAccess(req);
if (denied) return denied;
try {
@@ -40,6 +45,13 @@ export async function POST(
if (!record) {
return apiError(API_ERROR_CODES.INVALID_REQUEST, 404, `Course not found: ${courseId}`);
}
const proxied = await proxyLargeCourseControlToEngine({
request: req,
course: record,
action: 'framework-regenerate',
});
if (proxied) return proxied;
await assertLearningCourseMutable(courseId, record);
if (
isCourseGenerationRunning(courseId) ||
isCoursePublishing(courseId) ||
@@ -59,6 +71,9 @@ export async function POST(
detailUrl: `${baseUrl}/api/courses/${courseId}`,
});
} catch (error) {
if (error instanceof FrozenLearningCourseMutationError) {
return apiError(API_ERROR_CODES.INVALID_REQUEST, 409, error.message);
}
if (error instanceof CourseMutationInProgressError) {
return apiError(API_ERROR_CODES.INVALID_REQUEST, 409, error.message);
}