New features: - HLS video encoding/streaming (hls routes, hls-encoder) and a media transcripts pipeline (transcripts route + media-transcript queries) - AI assistant chat vs. run model: agent-course-generation worker/queue, run-monitor pane, chat-changes card, content ask-ai bar - Per-theme course-page previews across org landing-page themes (bold, classic, corporate, editorial, etc.) with a shared course token/component set - View-as-student mode and login-link / link-invite invite flows Refactor: - Extract packages/core consolidating config (env, storage, dashboard-url), services and utils previously duplicated under apps/api/src/config - Remove legacy agent service modules (chat-tools, chat-context, context-window, document, fetch-url, lesson-content) - Relax Cross-Origin-Resource-Policy to allow cross-origin media embedding - Add format script to tenant-router so turbo run format covers it
69 lines
2.7 KiB
TypeScript
69 lines
2.7 KiB
TypeScript
import { ZCourseContentDelete, ZCourseContentReorder, ZCourseContentUpdate } from '@cio/utils/validation/course';
|
|
import { deleteCourseContent, reorderCourseContent, updateCourseContent } from '@cio/core/services/course/content';
|
|
|
|
import { Hono } from '@api/utils/hono';
|
|
import { authOrAutomationKeyMiddleware } from '@api/middlewares/auth-or-automation-key';
|
|
import { authMiddleware } from '@api/middlewares/auth';
|
|
import { courseTeamMemberOrAutomationKeyMiddleware } from '@api/middlewares/course-team-member-or-automation-key';
|
|
import { courseTeamMemberMiddleware } from '@api/middlewares/course-team-member';
|
|
import { assertMcpAutomationUsageAllowed, recordMcpAutomationUsage } from '@api/services/organization/automation-usage';
|
|
import { handleError } from '@api/utils/errors';
|
|
import { zValidator } from '@hono/zod-validator';
|
|
|
|
export const contentRouter = new Hono()
|
|
.put(
|
|
'/reorder',
|
|
authOrAutomationKeyMiddleware,
|
|
courseTeamMemberOrAutomationKeyMiddleware(['course:write']),
|
|
zValidator('json', ZCourseContentReorder),
|
|
async (c) => {
|
|
try {
|
|
const courseId = c.req.param('courseId')!;
|
|
const automationKey = c.get('automationKey');
|
|
const payload = c.req.valid('json');
|
|
|
|
if (automationKey?.type === 'mcp') {
|
|
await assertMcpAutomationUsageAllowed(automationKey, 'reorder_course_content');
|
|
}
|
|
|
|
const result = await reorderCourseContent(courseId, payload);
|
|
|
|
if (automationKey?.type === 'mcp') {
|
|
await recordMcpAutomationUsage(automationKey, 'reorder_course_content', {
|
|
courseId,
|
|
sectionCount: payload.sections?.length ?? 0,
|
|
itemCount: payload.items?.length ?? 0
|
|
});
|
|
}
|
|
|
|
return c.json({ success: true, data: result }, 200);
|
|
} catch (error) {
|
|
return handleError(c, error, 'Failed to reorder course content');
|
|
}
|
|
}
|
|
)
|
|
.put('/', authMiddleware, courseTeamMemberMiddleware, zValidator('json', ZCourseContentUpdate), async (c) => {
|
|
try {
|
|
const courseId = c.req.param('courseId')!;
|
|
const { items } = c.req.valid('json');
|
|
|
|
await updateCourseContent(courseId, items);
|
|
|
|
return c.json({ success: true }, 200);
|
|
} catch (error) {
|
|
return handleError(c, error, 'Failed to update course content');
|
|
}
|
|
})
|
|
.delete('/', authMiddleware, courseTeamMemberMiddleware, zValidator('json', ZCourseContentDelete), async (c) => {
|
|
try {
|
|
const courseId = c.req.param('courseId')!;
|
|
const payload = c.req.valid('json');
|
|
|
|
await deleteCourseContent(courseId, payload);
|
|
|
|
return c.json({ success: true }, 200);
|
|
} catch (error) {
|
|
return handleError(c, error, 'Failed to delete course content');
|
|
}
|
|
});
|